asp將中文漢字字符轉(zhuǎn)為unicode編碼(\u編碼)與把unicode編碼轉(zhuǎn)為漢字
網(wǎng)絡(luò) 2019/4/16 11:19:50 深山行者 字體:
大 中 小 瀏覽 10380
<%
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ù):返回字符串的第一個(gè)字母對應(yīng)的ANSI字符代碼
'AscW函數(shù):返回每一個(gè)GB編碼文字的Unicode字符代碼
'hex函數(shù):返回表示十六進(jìn)制數(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類型強(qiáng)制轉(zhuǎn)換成int類型
'chr函數(shù):返回?cái)?shù)值對應(yīng)的ANSI編碼字符
'ChrW函數(shù):返回?cái)?shù)值對應(yīng)的Unicode編碼字符
unicodeto=unicodeto & ChrW(cint("&H" & mid(str,i,4)))
next
end function
%>
- 相關(guān)閱讀
- 江油旅游
- 推薦:ASP初學(xué)者常用源代碼總結(jié)篇
- div+css標(biāo)準(zhǔn)化在新窗口打開鏈接
- 河南中旅旅行社
- python對微信操作要用到這兩個(gè)庫wxpy與itchat
- 新疆中國國際旅行社有限責(zé)任公司
- 8種Python字符串拼接的方法,你知道幾種
- 四川悠旅地旅游有限公司
- 共有0條關(guān)于《asp將中文漢字字符轉(zhuǎn)為unicode編碼(\u編碼)與把unicode編碼轉(zhuǎn)為漢字》的評論
- 發(fā)表評論