asp将中文汉字字符转为unicode编码(\u编码)与把unicode编码转为汉字
网络 2019/4/16 11:19:50 深山行者 字体:
大 中 小 浏览 10206
<%
dim zhuan_text
zhuan_text = "深山工作室"
%>
要转换的内容:<%=zhuan_text%><br />
转换之后的代码:<%=tounicode(zhuan_text)%><br />
转码之后的文字:<%=unicodeto("\\u6df1\u5c71\u5de5\u4f5c\u5ba4")%><br />
<%
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
'\u6df1\u5c71\u5de5\u4f5c\u5ba4
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
%>
- 相关阅读
- 福建省武夷山旅行社官方网站
- CSS完美兼容IE6/IE7/FF的通用方法
- 深山留言板css安装教程
- 重庆长航江山国际旅行社
- 连云港市海州区培智学校
- 旅行社网站模板默认风格6
- SEO工具让你网站忧化更加随心所欲
- 网站内容中某个关键字相关右键菜单
- 共有0条关于《asp将中文汉字字符转为unicode编码(\u编码)与把unicode编码转为汉字》的评论
- 发表评论