asp将中文汉字字符转为unicode编码(\u编码)与把unicode编码转为汉字
网络 2019/4/16 11:19:50 深山行者 字体:
大 中 小 浏览 10184
<%
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
%>
- 相关阅读
- pywinauto技术文档
- 振辉消音器
- CSS设计中常见的精华问题收集
- 经典实用的触发型导航菜单
- 深山行者留言系统V3.2发布
- 利用CSS让网页里的提交按钮变得更漂亮
- 酷在旅途
- 深山旅行社管理系统免费版 V2.3
- 共有0条关于《asp将中文汉字字符转为unicode编码(\u编码)与把unicode编码转为汉字》的评论
- 发表评论