@@ -132,12 +132,8 @@ private static void writeStringSlowPath(JsonStream stream, String val, int i, in
132
132
if (escapeUnicode ) {
133
133
for (; i < valLen ; i ++) {
134
134
int c = val .charAt (i );
135
- if (c > 125 || c < 32 ) {
136
- byte b4 = (byte ) (c & 0xf );
137
- byte b3 = (byte ) (c >> 4 & 0xf );
138
- byte b2 = (byte ) (c >> 8 & 0xf );
139
- byte b1 = (byte ) (c >> 12 & 0xf );
140
- stream .write ((byte ) '\\' , (byte ) 'u' , ITOA [b1 ], ITOA [b2 ], ITOA [b3 ], ITOA [b4 ]);
135
+ if (c > 125 ) {
136
+ writeAsSlashU (stream , c );
141
137
} else {
142
138
writeAsciiChar (stream , c );
143
139
}
@@ -223,7 +219,19 @@ private static void writeAsciiChar(JsonStream stream, int c) throws IOException
223
219
stream .write ((byte ) '\\' , (byte ) 't' );
224
220
break ;
225
221
default :
226
- stream .write (c );
222
+ if (c < 32 ) {
223
+ writeAsSlashU (stream , c );
224
+ } else {
225
+ stream .write (c );
226
+ }
227
227
}
228
228
}
229
+
230
+ private static void writeAsSlashU (JsonStream stream , int c ) throws IOException {
231
+ byte b4 = (byte ) (c & 0xf );
232
+ byte b3 = (byte ) (c >> 4 & 0xf );
233
+ byte b2 = (byte ) (c >> 8 & 0xf );
234
+ byte b1 = (byte ) (c >> 12 & 0xf );
235
+ stream .write ((byte ) '\\' , (byte ) 'u' , ITOA [b1 ], ITOA [b2 ], ITOA [b3 ], ITOA [b4 ]);
236
+ }
229
237
}
0 commit comments