You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Yandell (JIRA)" <ji...@apache.org> on 2011/01/17 06:35:44 UTC
[jira] Closed: (LANG-646) StringEscapeUtils.unescapeJava doesn't
handle octal escapes and Unicode with extra u
[ https://issues.apache.org/jira/browse/LANG-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell closed LANG-646.
------------------------------
Resolution: Fixed
svn ci -m "Adding an OctalUnescaper to handle Java's support of 1->377 Octal values. LANG-646"
Sending src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
Adding src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java
Adding src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
Transmitting file data ...
Committed revision 1059753.
I didn't see much point in an OctalEscaper, so I didn't bother adding that. When escaping Java, we wouldn't know to escape a particular character to Octal for the aesthetic value.
It also only supports Java's 1->377 octal range; this is because Integer.parseInt(..., 8) only supports that. I didn't see any point in trying to do better than that given that the use case is primarily for Java at the moment.
> StringEscapeUtils.unescapeJava doesn't handle octal escapes and Unicode with extra u
> ------------------------------------------------------------------------------------
>
> Key: LANG-646
> URL: https://issues.apache.org/jira/browse/LANG-646
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Affects Versions: 2.5
> Environment: Irrelevant
> Reporter: polygenelubricants
> Priority: Minor
> Fix For: 3.0
>
>
> CODE TO REPRODUCE BUG:
> {noformat}
> System.out.println("\45");
> // %
> System.out.println(StringEscapeUtils.unescapeJava("\\45"));
> // 45, should be %
> System.out.println("\uu0030");
> // 0
> System.out.println(StringEscapeUtils.unescapeJava("\\uu0030"));
> // throws NestableRuntimeException:
> {noformat}
> This is not compliant with the JLS, which allows both [OctalEscape] and extraneous u for [UnicodeMarker] in Java string literal.
> REFERENCES:
> 3.10.6 Escape Sequences for Character and String Literals
> http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.6
> 3.3 Unicode Escapes
> http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.3
> EXTERNAL LINKS:
> http://stackoverflow.com/questions/3537706/howto-unescape-a-java-string-literal-in-java/
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.