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 @@ -214,7 +214,27 @@ exports.showCharImpl = function (c) {
214214} ;
215215
216216exports . showStringImpl = function ( s ) {
217- return JSON . stringify ( s ) ;
217+ var l = s . length ;
218+ return "\"" + s . replace (
219+ / [ \0 - \x1F \x7F " \\ ] / g,
220+ function ( c , i ) { // jshint ignore:line
221+ switch ( c ) {
222+ case "\"" :
223+ case "\\" :
224+ return "\\" + c ;
225+ case "\a" : return "\\a" ;
226+ case "\b" : return "\\b" ;
227+ case "\f" : return "\\f" ;
228+ case "\n" : return "\\n" ;
229+ case "\r" : return "\\r" ;
230+ case "\t" : return "\\t" ;
231+ case "\v" : return "\\v" ;
232+ }
233+ var k = i + 1 ;
234+ var empty = k < l && s [ k ] >= "0" && s [ k ] <= "9" ? "\\&" : "" ;
235+ return "\\" + c . charCodeAt ( 0 ) . toString ( 10 ) + empty ;
236+ }
237+ ) + "\"" ;
218238} ;
219239
220240exports . showArrayImpl = function ( f ) {
You can’t perform that action at this time.
0 commit comments