将unicode字符转换为字符串格式 [英] Converting unicode character to string format

查看:292
本文介绍了将unicode字符转换为字符串格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何在javascript中将unicode转换为字符串。例如:

Does anyone know how to convert a unicode to a string in javascript. For instance:

\ u2211 - > Σ
\ u0032 - > 2
\ u222B - > ∫

我基本上希望能够在xhtml或html中显示符号。尚未确定我将使用哪个。

I basically want to be able to display the symbol in xhtml or html. Haven't decided which I will be using yet.

推荐答案

刚找到方法:
String.fromCharCode(parseInt(unicode,16))返回正确的符号表示。这里的unicode只有数字前面没有 \u

Just found a way: String.fromCharCode(parseInt(unicode,16)) returns the right symbol representation. The unicode here doesn't have the \u in front of it just the number.

这篇关于将unicode字符转换为字符串格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆