1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Fixes code point output when unescaping code points. XML escapes are an entire code point, not surrogate pairs like in JSON.

This commit is contained in:
John J. Aylward 2016-09-22 15:40:26 -04:00
parent 68f92eb395
commit c11e09959c

View file

@ -165,15 +165,15 @@ public class XML {
if (semic > i) { if (semic > i) {
final String entity = string.substring(i + 1, semic); final String entity = string.substring(i + 1, semic);
if (entity.charAt(0) == '#') { if (entity.charAt(0) == '#') {
char cc; int cp;
if (entity.charAt(1) == 'x') { if (entity.charAt(1) == 'x') {
// hex encoded unicode // hex encoded unicode
cc = (char) Integer.parseInt(entity.substring(2), 16); cp = Integer.parseInt(entity.substring(2), 16);
} else { } else {
// decimal encoded unicode // decimal encoded unicode
cc = (char) Integer.parseInt(entity.substring(1)); cp = Integer.parseInt(entity.substring(1));
} }
sb.append(cc); sb.append(new String(Character.toChars(cp)));
} else { } else {
if ("quot".equalsIgnoreCase(entity)) { if ("quot".equalsIgnoreCase(entity)) {
sb.append('"'); sb.append('"');