Apache commons StringEscapeUtils.unescapeJava(“\\”)返回“”

时间:2013-04-15 14:48:26

标签: java stringescapeutils

以下代码:

final String INVALID_ESCAPE="\\";
System.out.println(String.format("'%s' -> '%s'", INVALID_ESCAPE, 
    StringEscapeUtils.unescapeJava(INVALID_ESCAPE)));

...生产:

'\' -> ''
控制台上的

。由于'\'不是有效的转义符,我希望在运行时出现异常。我错过了什么吗?

更新: 填写Apache jira

中的错误(?)报告

1 个答案:

答案 0 :(得分:2)

来自source

// TODO: throw "illegal character: \92" as an Exception if a \ on the end of the Java (as per the compiler)?

发送补丁;-)