Frage

The following code:

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

... produces:

'\' -> ''

on the console. Since '\' is not a valid escape I would expect an Exception at runtime. Am I missing anything?

UPDATE: filled a bug(?) report in Apache jira

War es hilfreich?

Lösung

From the source:

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

Send a patch ;-)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top