vb6 中文与unicode互相转换
================================================================================
'遇到错误,直接执行下一行。
On Error Resume Next
'unicode编码 转 中文
Dim Code As String
Dim Char As String
Code = Text1.Text '输入unicode编码
Code = Replace(Code, "U", "u")
p = Split(Code, "\u")
For i = 0 To UBound(p)
If Not p(i) = "" Then Char = Char & ChrW("&H" & p(i))
Next
Text1.Text = Char 'unicode编码 转 中文
'中文 转 unicode编码
Dim str As String
Dim sta As String
str = Text1.Text '输入中文
For i = 1 To Len(str)
sta = sta & "\u" & Hex(AscW(Mid(str, i, 1)))
Next
Text1.Text = sta '中文 转 unicode编码
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/ |