From c11e09959c546740963c0b8627f815b9f29c941e Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Thu, 22 Sep 2016 15:40:26 -0400 Subject: [PATCH] Fixes code point output when unescaping code points. XML escapes are an entire code point, not surrogate pairs like in JSON. --- XML.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/XML.java b/XML.java index 8e63c74..890b2de 100644 --- a/XML.java +++ b/XML.java @@ -165,15 +165,15 @@ public class XML { if (semic > i) { final String entity = string.substring(i + 1, semic); if (entity.charAt(0) == '#') { - char cc; + int cp; if (entity.charAt(1) == 'x') { // hex encoded unicode - cc = (char) Integer.parseInt(entity.substring(2), 16); + cp = Integer.parseInt(entity.substring(2), 16); } else { // 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 { if ("quot".equalsIgnoreCase(entity)) { sb.append('"');