mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
fixes code point appends to string builder
This commit is contained in:
parent
c11e09959c
commit
f58a0f4684
12
XML.java
12
XML.java
@ -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('"');
|
||||
|
Loading…
x
Reference in New Issue
Block a user