asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字
網絡 2019/4/16 11:19:50 深山行者 字體:
大 中 小 瀏覽 10245
<%
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
%>
- 相關閱讀
- 留言板留言板V7.21
- 一行兩列的CSS設置代碼
- 深山仿QQ愛墻最新版--新的一年,新的界面,新的功能
- 購物時某件商品倒計時銷售非常不錯
- 相愉草原旅游網
- CSS Alpha透明代碼相關知識學習
- 旅行社手機網站模板3
- 易游天下通-中南國際旅游公司
- 共有0條關于《asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字》的評論
- 發表評論