怎样才能转换下面的unicode代码 为中文可读的

zjm1126qqcom 2010-01-19 10:08:27


var a={
userName: "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
userNameMin: "\u4e0d\u80fd\u5c0f\u4e8e4\u4e2a\u5b57",
userNameMax: "\u4e0d\u80fd\u8d85\u8fc712\u4e2a\u5b57",
userNameExist: "\u8be5\u7528\u6237\u540d\u5df2\u88ab\u6ce8\u518c\u4e86\uff0c\u8bf7\u6362\u6362",
userNameInvalid: "\u53ea\u652f\u6301\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
userNameStartInvalid: "\u7528\u6237\u540d\u4e0d\u80fd\u4ee5\u4e0b\u5212\u7ebf\u5f00\u5934",
nickName: "6\u4f4d\u4ee5\u5185\u4e2d\u6587\u621612\u4f4d\u4ee5\u5185\u82f1\u6587\u5b57\u7b26",
nickNameMin: "\u4e0d\u80fd\u5c0f\u4e8e1\u4e2a\u5b57",
nickNameMax: "\u4e0d\u80fd\u8d85\u8fc76\u4e2a\u6c49\u5b57\u621612\u4e2a\u82f1\u6587\u5b57\u7b26",
nickNameExist: "\u8be5\u540d\u5b57\u5df2\u88ab\u5360\u7528\uff0c\u8bf7\u6362\u6362",
nickNameInvalid: "\u53ea\u652f\u6301\u4e2d\u6587\u3001\u5b57\u6bcd\u6216\u6570\u5b57\uff0c\u4e0d\u652f\u6301\u7a7a\u683c\u548c\u7279\u6b8a\u7b26\u53f7",
nickNameError: "\u540d\u5b57\u4e2d\u542b\u6709\u8fdd\u7981\u8bcd\uff0c\u8bf7\u4fee\u6539\uff0c\u671b\u8c05\u89e3",
password: "6-16\u4f4d\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
passwordMin: "\u4e0d\u80fd\u5c0f\u4e8e6\u4e2a\u5b57\u7b26",
passwordMax: "\u4e0d\u80fd\u8d85\u8fc716\u4e2a\u5b57\u7b26",
passwordInvalid: "\u53ea\u652f\u6301\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
password1: "\u8bf7\u518d\u786e\u8ba4\u4e00\u6b21\u4f60\u8f93\u5165\u7684\u5bc6\u7801",
password1Invalid: "\u4e24\u6b21\u5bc6\u7801\u8f93\u5165\u4e0d\u4e00\u81f4",
email: "\u8bf7\u8f93\u5165\u4f60\u5e38\u7528\u7684Email",
emailExist: "\u8be5Email\u5df2\u88ab\u6ce8\u518c",
emailInvalid: "Email\u683c\u5f0f\u4e0d\u6b63\u786e",
sex: "\u8bf7\u9009\u62e9\u4f60\u7684\u6027\u522b",
validateCode: "\u8bf7\u8f93\u5165\u56fe\u50cf\u4e2d\u7684\u6587\u5b57",
validateCodeInvalid: "\u9a8c\u8bc1\u7801\u9519\u8bef",
loading: '<img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> \u6b63\u5728\u68c0\u67e5\u552f\u4e00\u6027',
checkCode: '<img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> \u6b63\u5728\u68c0\u67e5\u9a8c\u8bc1\u7801',
ok: '<img align="absmiddle" alt="ok" src="http://images.digu.com/web_res_v1/images/ico_valid.gif" />',
required: "\u5fc5\u586b"
}

...全文
5713 6 打赏 收藏 举报
写回复
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yixianggao 2010-01-19
  • 打赏
  • 举报
回复
\un 匹配 n,其中 n 是一个用四个十六进制数字表示的 Unicode 字符。例如, \u00A9 匹配版权符号 (?)。
例如:"4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf"
页面是可以直接解释的,无需任何转换
4-12个英文字母、数字和下划线

如果想从中文得到类似结果,可以用 escape,然后将 % 号替换为 \ 即可!
document.write(escape("4-12个英文字母、数字和下划线"));
//4-12%u4E2A%u82F1%u6587%u5B57%u6BCD%u3001%u6570%u5B57%u548C%u4E0B%u5212%u7EBF

sohighthesky 2010-01-19
  • 打赏
  • 举报
回复
var hexToDec = function(str) {
str=str.replace(/\\/g,"%");
return unescape(str);
}
alert(hexToDec("\u8bf7\u518d\u786e\u8ba4\u4e00"));
草根醉秋意 2010-01-19
  • 打赏
  • 举报
回复
alert("4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf");
yixianggao 2010-01-19
  • 打赏
  • 举报
回复
直接输出

L@_@K

var a={
userName: "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
userNameMin: "\u4e0d\u80fd\u5c0f\u4e8e4\u4e2a\u5b57",
userNameMax: "\u4e0d\u80fd\u8d85\u8fc712\u4e2a\u5b57",
userNameExist: "\u8be5\u7528\u6237\u540d\u5df2\u88ab\u6ce8\u518c\u4e86\uff0c\u8bf7\u6362\u6362",
userNameInvalid: "\u53ea\u652f\u6301\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
userNameStartInvalid: "\u7528\u6237\u540d\u4e0d\u80fd\u4ee5\u4e0b\u5212\u7ebf\u5f00\u5934",
nickName: "6\u4f4d\u4ee5\u5185\u4e2d\u6587\u621612\u4f4d\u4ee5\u5185\u82f1\u6587\u5b57\u7b26",
nickNameMin: "\u4e0d\u80fd\u5c0f\u4e8e1\u4e2a\u5b57",
nickNameMax: "\u4e0d\u80fd\u8d85\u8fc76\u4e2a\u6c49\u5b57\u621612\u4e2a\u82f1\u6587\u5b57\u7b26",
nickNameExist: "\u8be5\u540d\u5b57\u5df2\u88ab\u5360\u7528\uff0c\u8bf7\u6362\u6362",
nickNameInvalid: "\u53ea\u652f\u6301\u4e2d\u6587\u3001\u5b57\u6bcd\u6216\u6570\u5b57\uff0c\u4e0d\u652f\u6301\u7a7a\u683c\u548c\u7279\u6b8a\u7b26\u53f7",
nickNameError: "\u540d\u5b57\u4e2d\u542b\u6709\u8fdd\u7981\u8bcd\uff0c\u8bf7\u4fee\u6539\uff0c\u671b\u8c05\u89e3",
password: "6-16\u4f4d\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
passwordMin: "\u4e0d\u80fd\u5c0f\u4e8e6\u4e2a\u5b57\u7b26",
passwordMax: "\u4e0d\u80fd\u8d85\u8fc716\u4e2a\u5b57\u7b26",
passwordInvalid: "\u53ea\u652f\u6301\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
password1: "\u8bf7\u518d\u786e\u8ba4\u4e00\u6b21\u4f60\u8f93\u5165\u7684\u5bc6\u7801",
password1Invalid: "\u4e24\u6b21\u5bc6\u7801\u8f93\u5165\u4e0d\u4e00\u81f4",
email: "\u8bf7\u8f93\u5165\u4f60\u5e38\u7528\u7684Email",
emailExist: "\u8be5Email\u5df2\u88ab\u6ce8\u518c",
emailInvalid: "Email\u683c\u5f0f\u4e0d\u6b63\u786e",
sex: "\u8bf7\u9009\u62e9\u4f60\u7684\u6027\u522b",
validateCode: "\u8bf7\u8f93\u5165\u56fe\u50cf\u4e2d\u7684\u6587\u5b57",
validateCodeInvalid: "\u9a8c\u8bc1\u7801\u9519\u8bef",
loading: '<img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> \u6b63\u5728\u68c0\u67e5\u552f\u4e00\u6027',
checkCode: '<img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> \u6b63\u5728\u68c0\u67e5\u9a8c\u8bc1\u7801',
ok: '<img align="absmiddle" alt="ok" src="http://images.digu.com/web_res_v1/images/ico_valid.gif" />',
required: "\u5fc5\u586b"
}
for (var p in a) {
document.write(p, ": ", a[p], "<br />");
}
云中雁荡山 2010-01-19
  • 打赏
  • 举报
回复
将unicode字符集转换为gb2312或者是utf-8看看
nta5107179 2010-01-19
  • 打赏
  • 举报
回复
看不懂,期待解决
相关推荐
发帖
JavaScript

8.7w+

社区成员

Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
帖子事件
创建了帖子
2010-01-19 10:08
社区公告
暂无公告