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

查看:59
本文介绍了将 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天全站免登陆