【发布时间】:2014-02-04 08:31:16
【问题描述】:
有没有办法将 HTML 实体转换为 Javascript 中的 unicode 字符?
我试过了
var unicodeHtmlEntity = function (t) {
numericValue = parseInt(t.slice(2, -1), 10);
numericValue = numericValue.toString(16);
return "\\u" + numericValue;
};
函数可以像€ 一样调用,但返回字符串\u20ac,而不是 € 的 unicode 字符。有什么想法吗?
【问题讨论】:
-
我认为这与这个线程相同:stackoverflow.com/questions/3835317/…希望这有帮助!
标签: javascript unicode html-entities