2016-11-24 9:13:13 | 作者:老铁SEO | 4个评论 | 人浏览
<% dim str : str="凌陈亮" response.write("<p>" & tounicode(str) & "</p>") response.write("<p>" & unicodeto(tounicode(str)) & "</p>") function tounicode(str) '中文转unicode tounicode="" dim i for i=1 to len(str) 'asc函数:返回字符串的第一个字母对应的ANSI字符代码 'AscW函数:返回每一个GB编码文字的Unicode字符代码 'hex函数:返回表示十六进制数字值的字符串 tounicode=tounicode & "\u" & LCase(Right("0000" & Cstr(hex(AscW(mid(str,i,1)))),4)) next end function '\u51cc\u9648\u4eae\u535a\u5ba2 function unicodeto(str) 'unicode转中文 str=replace(str,"\u","") unicodeto="" dim i for i=1 to len(str) step 4 'cint函数:将Variant类型强制转换成int类型 'chr函数:返回数值对应的ANSI编码字符 'ChrW函数:返回数值对应的Unicode编码字符 unicodeto=unicodeto & ChrW(cint("&H" & mid(str,i,4))) next end function %>
输出结果:
\u51cc\u9648\u4eae
凌陈亮