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:
parent
c11e09959c
commit
f58a0f4684
1 changed files with 6 additions and 6 deletions
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…
Add table
Add a link
Reference in a new issue