经常会用到正则,要验证中文,就找了点关于unicode的资料
字符串转 UCS2
UCS2 转字符串
另:CJK字符集从\u4e00-\u9fff,具体参见
http://unicode.org/charts/
http://www.unicode.org/charts/PDF/U4E00.pdf
http://en.wikipedia.org/wiki/Han_unification
字符串转 UCS2
var unicode = '', str = '中文';
for (var i=0; i<str.length; i++) {
unicode += '\\u'+str.charCodeAt(i).toString(16);
}
console.log(unicode); // => \u4e2d\u6587
UCS2 转字符串
var s = "\u4e2d\u6587";
s.toString(); // => 中文
另:CJK字符集从\u4e00-\u9fff,具体参见
http://unicode.org/charts/
http://www.unicode.org/charts/PDF/U4E00.pdf
http://en.wikipedia.org/wiki/Han_unification
本文介绍了如何使用Unicode编码处理中文字符串。通过JavaScript示例代码展示了字符串与Unicode之间的转换方法,并给出了CJK字符集的具体范围。
2940

被折叠的 条评论
为什么被折叠?



