asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字
網絡 2019/4/16 11:19:50 深山行者 字體:
大 中 小 瀏覽 10483
<%
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
%>
- 相關閱讀
- asp 當日訪問量,全部訪問量,當前在線人數統計
- 實現iis6與iis7環境下支持mp4視頻隨意拖動、預覽播放、邊下載邊播放
- 山西出國服務網
- 旅行社網站模板3
- 石家莊長興國際旅行社
- 深山行者個人網站程序V0.2 效果圖
- 深山行者留言系統V2.3
- radio單選按鈕組選擇詳細
- 共有0條關于《asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字》的評論
- 發表評論