Skip to content

Instantly share code, notes, and snippets.

@shenmao1989
Created August 14, 2012 04:06
Show Gist options
  • Save shenmao1989/3346179 to your computer and use it in GitHub Desktop.
Save shenmao1989/3346179 to your computer and use it in GitHub Desktop.
如何将汉字转换成Unicode格式
var classObj=
{
ToUnicode:function(str)
{
return escape(str).replace(/%/g,"\\").toLowerCase();
},
UnUnicode:function(str)
{
return unescape(str.replace(/\\/g, "%"));
}
}
alert(classObj.ToUnicode("必须输入"));
alert(classObj.UnUnicode("\u5fc5\u987b\u8f93\u5165"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment