asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字
網絡 2019/4/16 11:19:50 深山行者 字體:
大 中 小 瀏覽 10246
<%
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
%>
- 相關閱讀
- python里面requests.post返回的res.text還有其它的嗎
- pywinauto技術文檔
- 隨心所欲的定制彈出窗口
- 發出億萬中國人的心聲,釣魚島事件以來最愛國的視頻
- 深山旅行社網站管理系統 v1.5
- 松原市海航商務旅行社
- 自由鳥
- ASP中Utf-8與Gb2312編碼轉換亂碼問題的解決方法頁面編碼聲明
- 共有0條關于《asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字》的評論
- 發表評論