Created
August 14, 2012 04:06
-
-
Save shenmao1989/3346179 to your computer and use it in GitHub Desktop.
如何将汉字转换成Unicode格式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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