admin管理员组文章数量:1325079
I'm trying to use a variable and \u to create an UTF character with Node.js.
var code = '0045';
console.log('\u0045', '\u' + code);
But the output bees
E u0045
How do I make it
E E
How do I create the character and store it in a variable?
I'm trying to use a variable and \u to create an UTF character with Node.js.
var code = '0045';
console.log('\u0045', '\u' + code);
But the output bees
E u0045
How do I make it
E E
How do I create the character and store it in a variable?
Share asked Mar 30, 2011 at 20:53 tirithentirithen 3,52711 gold badges43 silver badges67 bronze badges 1-
1
Why don't you use
String.fromCharCode(n)
? See developer.mozilla/en/JavaScript/Reference/Global_Objects/… – Elian Ebbing Commented Mar 30, 2011 at 20:59
1 Answer
Reset to default 12Use String.fromCharCode
:
String.fromCharCode(0x0045)
String.fromCharCode(parseInt('0045', 16))
本文标签: utf 8How to create UTF characters dynamically with JavaScriptStack Overflow
版权声明:本文标题:utf 8 - How to create UTF characters dynamically with JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742144556a2422730.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论