File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,27 @@ exports.showCharImpl = function (c) {
227227} ;
228228
229229exports . showStringImpl = function ( s ) {
230- return JSON . stringify ( s ) ;
230+ var l = s . length ;
231+ return "\"" + s . replace (
232+ / [ \0 - \x1F \x7F " \\ ] / g,
233+ function ( c , i ) { // jshint ignore:line
234+ switch ( c ) {
235+ case "\"" :
236+ case "\\" :
237+ return "\\" + c ;
238+ case "\a" : return "\\a" ;
239+ case "\b" : return "\\b" ;
240+ case "\f" : return "\\f" ;
241+ case "\n" : return "\\n" ;
242+ case "\r" : return "\\r" ;
243+ case "\t" : return "\\t" ;
244+ case "\v" : return "\\v" ;
245+ }
246+ var k = i + 1 ;
247+ var empty = k < l && s [ k ] >= "0" && s [ k ] <= "9" ? "\\&" : "" ;
248+ return "\\" + c . charCodeAt ( 0 ) . toString ( 10 ) + empty ;
249+ }
250+ ) + "\"" ;
231251} ;
232252
233253exports . showArrayImpl = function ( f ) {
You can’t perform that action at this time.
0 commit comments