|
|
@ -12,8 +12,6 @@ var js = {
|
|
|
|
* may appear in the form of an escape sequence.
|
|
|
|
* may appear in the form of an escape sequence.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* For portability, we also escape all control and non-ASCII characters.
|
|
|
|
* For portability, we also escape all control and non-ASCII characters.
|
|
|
|
* Note that the "\v" escape sequence is not used because IE does not like
|
|
|
|
|
|
|
|
* it.
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
return s
|
|
|
|
return s
|
|
|
|
.replace(/\\/g, '\\\\') // backslash
|
|
|
|
.replace(/\\/g, '\\\\') // backslash
|
|
|
@ -22,6 +20,7 @@ var js = {
|
|
|
|
.replace(/\x08/g, '\\b') // backspace
|
|
|
|
.replace(/\x08/g, '\\b') // backspace
|
|
|
|
.replace(/\t/g, '\\t') // horizontal tab
|
|
|
|
.replace(/\t/g, '\\t') // horizontal tab
|
|
|
|
.replace(/\n/g, '\\n') // line feed
|
|
|
|
.replace(/\n/g, '\\n') // line feed
|
|
|
|
|
|
|
|
.replace(/\v/g, '\\v') // vertical tab
|
|
|
|
.replace(/\f/g, '\\f') // form feed
|
|
|
|
.replace(/\f/g, '\\f') // form feed
|
|
|
|
.replace(/\r/g, '\\r') // carriage return
|
|
|
|
.replace(/\r/g, '\\r') // carriage return
|
|
|
|
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
|
|
|
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
|
|
@ -37,17 +36,17 @@ var js = {
|
|
|
|
* For portability, we also escape all control and non-ASCII characters.
|
|
|
|
* For portability, we also escape all control and non-ASCII characters.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
return s
|
|
|
|
return s
|
|
|
|
.replace(/\\/g, '\\\\') // backslash
|
|
|
|
.replace(/\\/g, '\\\\') // backslash
|
|
|
|
.replace(/\//g, '\\/') // closing slash
|
|
|
|
.replace(/\//g, '\\/') // closing slash
|
|
|
|
.replace(/\]/g, '\\]') // closing bracket
|
|
|
|
.replace(/\]/g, '\\]') // closing bracket
|
|
|
|
.replace(/\^/g, '\\^') // caret
|
|
|
|
.replace(/\^/g, '\\^') // caret
|
|
|
|
.replace(/-/g, '\\-') // dash
|
|
|
|
.replace(/-/g, '\\-') // dash
|
|
|
|
.replace(/\0/g, '\\0') // null
|
|
|
|
.replace(/\0/g, '\\0') // null
|
|
|
|
.replace(/\t/g, '\\t') // horizontal tab
|
|
|
|
.replace(/\t/g, '\\t') // horizontal tab
|
|
|
|
.replace(/\n/g, '\\n') // line feed
|
|
|
|
.replace(/\n/g, '\\n') // line feed
|
|
|
|
.replace(/\v/g, '\\x0B') // vertical tab
|
|
|
|
.replace(/\v/g, '\\v') // vertical tab
|
|
|
|
.replace(/\f/g, '\\f') // form feed
|
|
|
|
.replace(/\f/g, '\\f') // form feed
|
|
|
|
.replace(/\r/g, '\\r') // carriage return
|
|
|
|
.replace(/\r/g, '\\r') // carriage return
|
|
|
|
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
|
|
|
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
|
|
|
.replace(/[\x10-\x1F\x7F-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
|
|
|
|
.replace(/[\x10-\x1F\x7F-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
|
|
|
|
.replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
|
|
|
|
.replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
|
|
|
|