asp將中文漢字字符轉(zhuǎn)為unicode編碼(\u編碼)與把unicode編碼轉(zhuǎn)為漢字
網(wǎng)絡(luò) 2019/4/16 11:19:50 深山行者 字體:
大 中 小 瀏覽 10266
<%
dim zhuan_text
zhuan_text = "深山工作室"
%>
要轉(zhuǎn)換的內(nèi)容:<%=zhuan_text%><br />
轉(zhuǎn)換之后的代碼:<%=tounicode(zhuan_text)%><br />
轉(zhuǎn)碼之后的文字:<%=unicodeto("\\u6df1\u5c71\u5de5\u4f5c\u5ba4")%><br />
<%
function tounicode(str) '中文轉(zhuǎn)unicode
tounicode=""
dim i
for i=1 to len(str)
'asc函數(shù):返回字符串的第一個字母對應(yīng)的ANSI字符代碼
'AscW函數(shù):返回每一個GB編碼文字的Unicode字符代碼
'hex函數(shù):返回表示十六進制數(shù)字值的字符串
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轉(zhuǎn)中文
str=replace(str,"\u","")
unicodeto=""
dim i
for i=1 to len(str) step 4
'cint函數(shù):將Variant類型強制轉(zhuǎn)換成int類型
'chr函數(shù):返回數(shù)值對應(yīng)的ANSI編碼字符
'ChrW函數(shù):返回數(shù)值對應(yīng)的Unicode編碼字符
unicodeto=unicodeto & ChrW(cint("&H" & mid(str,i,4)))
next
end function
%>
- 相關(guān)閱讀
- 另外的一種可以計算的倒計時效果
- 過濾輸入字符串中的危險符號
- 國內(nèi)各大搜索引擎的蜘蛛名稱列表
- 另外一種符合web2.0的鏈接打開方式--利用base打開鏈接
- 格式化金錢如果為0增加兩個小數(shù)點
- 深山行者留言系統(tǒng)V1.0 (簡稱深山留言V1.0)
- 絕對可以用的IE6綠色版下載
- 中國青島春秋國際旅行社有限公司
- 共有0條關(guān)于《asp將中文漢字字符轉(zhuǎn)為unicode編碼(\u編碼)與把unicode編碼轉(zhuǎn)為漢字》的評論
- 發(fā)表評論