Node.js/Unicode
来自康健生活
< Node.js
引言
Unicode 与 String 互转(中文)
Unicode 转 String
eval("'" + string + "'");
当 string 中有带分号'或者"时,会报错,所以使用 eval('"' + string + '"'),eq:
(new Function("return '" + string + "'"))();
unescape(string.replace(/\u/g, "%u"));
String 转 Unicode
"\\u" + string.charCodeAt(i).toString(16);
Unicode 与 String 互转(中英文)
Unicode 转 String
No categories