asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字
網絡 2019/4/16 11:19:50 深山行者 字體:
大 中 小 瀏覽 10297
<%
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
%>
- 相關閱讀
- 仿淘寶首頁商品分類列表效果
- 微信小程序騰訊視頻播放組件tencentvideo(wxa75efa648b60994b)
- 連云港門窗制作
- 一個select表單移處數據的效果,非常好用。
- asp統計信息/文章每日、每周、每月、總訪問量的方法
- 深山留言板情人節效果
- 超強的中間自適應,左右固定,有許多值得學習的地方
- asp事務處理 for mssql
- 共有0條關于《asp將中文漢字字符轉為unicode編碼(\u編碼)與把unicode編碼轉為漢字》的評論
- 發表評論