asp將中文漢字字符轉(zhuǎn)為unicode編碼(\u編碼)與把unicode編碼轉(zhuǎn)為漢字
網(wǎng)絡(luò) 2019/4/16 11:19:50 深山行者 字體:
大 中 小 瀏覽 10382
<%
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è)字母對(duì)應(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ù)值對(duì)應(yīng)的ANSI編碼字符
'ChrW函數(shù):返回?cái)?shù)值對(duì)應(yīng)的Unicode編碼字符
unicodeto=unicodeto & ChrW(cint("&H" & mid(str,i,4)))
next
end function
%>
- 相關(guān)閱讀
- asp正則表達(dá)式 替換HTML源文件里的鏈接地址
- 深山留言板母親節(jié)效果
- asp中最難發(fā)現(xiàn)的錯(cuò)誤由最簡單的程序引起
- GOOGLE百度破解,網(wǎng)站優(yōu)化SEO最終詳解
- NameError: name ‘xxx‘ is not defined問題總結(jié)
- 連云港旅游網(wǎng)
- 仿MAC官網(wǎng)導(dǎo)航菜單
- CSS的十八般技巧
- 共有0條關(guān)于《asp將中文漢字字符轉(zhuǎn)為unicode編碼(\u編碼)與把unicode編碼轉(zhuǎn)為漢字》的評(píng)論
- 發(fā)表評(píng)論