Skip to content

Commit c11e099

Browse files
author
John J. Aylward
committed
Fixes code point output when unescaping code points. XML escapes are an entire code point, not surrogate pairs like in JSON.
1 parent 68f92eb commit c11e099

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎XML.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ public static String unescape(String string) {
165165
if (semic > i) {
166166
final String entity = string.substring(i + 1, semic);
167167
if (entity.charAt(0) == '#') {
168-
char cc;
168+
int cp;
169169
if (entity.charAt(1) == 'x') {
170170
// hex encoded unicode
171-
cc = (char) Integer.parseInt(entity.substring(2), 16);
171+
cp = Integer.parseInt(entity.substring(2), 16);
172172
} else {
173173
// decimal encoded unicode
174-
cc = (char) Integer.parseInt(entity.substring(1));
174+
cp = Integer.parseInt(entity.substring(1));
175175
}
176-
sb.append(cc);
176+
sb.append(new String(Character.toChars(cp)));
177177
} else {
178178
if ("quot".equalsIgnoreCase(entity)) {
179179
sb.append('"');

0 commit comments

Comments
 (0)