From fac34bfab345bf8febef23f4484607e26010db0f Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Wed, 1 Jun 2011 19:29:28 -0400 Subject: [PATCH] Support for super-ASCII weird characters too. --- lib/jsdecomp.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jsdecomp.js b/lib/jsdecomp.js index f866e0b..c2ced33 100644 --- a/lib/jsdecomp.js +++ b/lib/jsdecomp.js @@ -85,15 +85,15 @@ Narcissus.decompiler = (function() { } function nodeStr(n) { - if (/[\u0000-\u001F]/.test(n.value)) { - // use the convoluted algorithm to avoid broken low characters + if (/[\u0000-\u001F\u0080-\uFFFF]/.test(n.value)) { + // use the convoluted algorithm to avoid broken low/high characters var str = ""; for (var i = 0; i < n.value.length; i++) { var c = n.value[i]; - if (c <= "\x1F") { + if (c <= "\x1F" || c >= "\x80") { var cc = c.charCodeAt(0).toString(16); - if (cc.length === 1) cc = "0" + cc; - str += "\\u00" + cc; + while (cc.length < 4) cc = "0" + cc; + str += "\\u" + cc; } else { str += nodeStrEscape(c); }