From: Andreas Lind Petersen Date: Sun, 31 Mar 2013 09:07:31 +0000 (+0200) Subject: Output, to_ascii: Escape non-ascii chars with \xnn instead of \unnnn whenever possible. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=81f5efe39a6d44d3037dda8bcff01195f5699139;p=UglifyJS.git Output, to_ascii: Escape non-ascii chars with \xnn instead of \unnnn whenever possible. --- diff --git a/lib/output.js b/lib/output.js index 42b3aad9..b99bfa63 100644 --- a/lib/output.js +++ b/lib/output.js @@ -72,8 +72,13 @@ function OutputStream(options) { function to_ascii(str) { return str.replace(/[\u0080-\uffff]/g, function(ch) { var code = ch.charCodeAt(0).toString(16); - while (code.length < 4) code = "0" + code; - return "\\u" + code; + if (code.length <= 2) { + while (code.length < 2) code = "0" + code; + return "\\x" + code; + } else { + while (code.length < 4) code = "0" + code; + return "\\u" + code; + } }); };