File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ export function stringify_string(str) {
63
63
result += '\\"' ;
64
64
} else if ( char in escaped ) {
65
65
result += escaped [ char ] ;
66
+ } else if ( code <= 0x001F ) {
67
+ result += `\\u${ code . toString ( 16 ) . toUpperCase ( ) . padStart ( 4 , "0" ) } `
66
68
} else if ( code >= 0xd800 && code <= 0xdfff ) {
67
69
const next = str . charCodeAt ( i + 1 ) ;
68
70
Original file line number Diff line number Diff line change @@ -200,6 +200,18 @@ const fixtures = {
200
200
js : '"\\u0000"' ,
201
201
json : '["\\u0000"]'
202
202
} ,
203
+ {
204
+ name : 'control character' ,
205
+ value : '\u0001' ,
206
+ js : '"\\u0001"' ,
207
+ json : '["\\u0001"]'
208
+ } ,
209
+ {
210
+ name : 'control character extremum' ,
211
+ value : '\u001F' ,
212
+ js : '"\\u001F"' ,
213
+ json : '["\\u001F"]'
214
+ } ,
203
215
{
204
216
name : 'backslash' ,
205
217
value : '\\' ,
You can’t perform that action at this time.
0 commit comments