您的位置:首页 > 编程语言 > PHP开发

thinkphp设置路由失效的问题

2012-07-19 23:53 417 查看
经常会用到正则,要验证中文,就找了点关于unicode的资料

字符串转 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: