Skip to content

Commit 73a40bf

Browse files
committed
Support 4-byte unicode escape sequences in string literals.
1 parent e8637a4 commit 73a40bf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonTreeTranslator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,17 @@ private static String unescapeJavaString(String st) {
730730
sb.append(Character.toChars(code));
731731
i += 5;
732732
continue;
733+
// Hex Unicode: U????????
734+
case 'U':
735+
if (i >= st.length() - 9) {
736+
ch = 'U';
737+
break;
738+
}
739+
code = Integer.parseInt(st.substring(i + 2, i + 10), 16);
740+
sb.append(Character.toChars(code));
741+
i += 9;
742+
continue;
743+
// Hex Unicode: x??
733744
case 'x':
734745
if (i >= st.length() - 3) {
735746
ch = 'u';

0 commit comments

Comments
 (0)