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 appends to string builder

This commit is contained in:
John J. Aylward 2016-09-22 16:10:49 -04:00
parent c11e09959c
commit f58a0f4684

View file

@ -119,8 +119,8 @@ public class XML {
*/
public static String escape(String string) {
StringBuilder sb = new StringBuilder(string.length());
for (final int c : codePointIterator(string)) {
switch (c) {
for (final int cp : codePointIterator(string)) {
switch (cp) {
case '&':
sb.append("&");
break;
@ -137,12 +137,12 @@ public class XML {
sb.append("'");
break;
default:
if (Character.isISOControl(c)) {
if (Character.isISOControl(cp)) {
sb.append("&#x");
sb.append(Integer.toHexString(c));
sb.append(Integer.toHexString(cp));
sb.append(";");
} else {
sb.append(new String(Character.toChars(c)));
sb.appendCodePoint(cp);
}
}
}
@ -173,7 +173,7 @@ public class XML {
// decimal encoded unicode
cp = Integer.parseInt(entity.substring(1));
}
sb.append(new String(Character.toChars(cp)));
sb.appendCodePoint(cp);
} else {
if ("quot".equalsIgnoreCase(entity)) {
sb.append('"');