Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f58a0f4

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

File tree

Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Open diff view settings
Collapse file

‎XML.java‎

Copy file name to clipboardExpand all lines: XML.java
+6-6Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.