Skip to content

Commit f58a0f4

Browse files
author
John J. Aylward
committed
fixes code point appends to string builder
1 parent c11e099 commit f58a0f4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

XML.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public void remove() {
119119
*/
120120
public static String escape(String string) {
121121
StringBuilder sb = new StringBuilder(string.length());
122-
for (final int c : codePointIterator(string)) {
123-
switch (c) {
122+
for (final int cp : codePointIterator(string)) {
123+
switch (cp) {
124124
case '&':
125125
sb.append("&");
126126
break;
@@ -137,12 +137,12 @@ public static String escape(String string) {
137137
sb.append("'");
138138
break;
139139
default:
140-
if (Character.isISOControl(c)) {
140+
if (Character.isISOControl(cp)) {
141141
sb.append("&#x");
142-
sb.append(Integer.toHexString(c));
142+
sb.append(Integer.toHexString(cp));
143143
sb.append(";");
144144
} else {
145-
sb.append(new String(Character.toChars(c)));
145+
sb.appendCodePoint(cp);
146146
}
147147
}
148148
}
@@ -173,7 +173,7 @@ public static String unescape(String string) {
173173
// decimal encoded unicode
174174
cp = Integer.parseInt(entity.substring(1));
175175
}
176-
sb.append(new String(Character.toChars(cp)));
176+
sb.appendCodePoint(cp);
177177
} else {
178178
if ("quot".equalsIgnoreCase(entity)) {
179179
sb.append('"');

0 commit comments

Comments
 (0)