function eatEscape(inStr){ return inStr.replace(/[^\*\+\-\.\/\d@A-Z_]/gi, function (chr){ var code = chr.charCodeAt(0); return code > 0xff ? "%u" + (code > 0xfff ? "" : "0") + code.toString(16).toUpperCase() : "%" + (code > 0xf ? "" : "0") + code.toString(16).toUpperCase(); }); } function eatUnescape(inStr){ return inStr.replace(/%u[\dA-Fa-f]{4}|%[\dA-Fa-f]{2}/g, function (enc){ return String.fromCharCode(parseInt("0x" + (enc.match(/%u/) ? enc.substring(2, 6) : enc.substring(1, 3)))); }); }