vb中如何将字符串转换为utf-8编码
VB6.0当中有没有像PHP的mb_convert_encoding函数,可以把一段字符串从UTF-8转换为GB2312,或者反过来转换PHP中自带这个函数mb_conv...
VB6.0当中有没有像PHP的mb_convert_encoding函数,可以把一段字符串从UTF-8转换为GB2312,或者反过来转换
PHP中自带这个函数mb_convert_encoding("中文","utf-8","gb2312")可以把汉字由GB2312转换为UTF-8编码,VB中怎么实现这样的函数功能啊??
在网上找了个GB2UTF的URL函数,还有Unicode2utf函数结合使用搞定了,分就给你了,没人给出具体的代码,呵呵 展开
PHP中自带这个函数mb_convert_encoding("中文","utf-8","gb2312")可以把汉字由GB2312转换为UTF-8编码,VB中怎么实现这样的函数功能啊??
在网上找了个GB2UTF的URL函数,还有Unicode2utf函数结合使用搞定了,分就给你了,没人给出具体的代码,呵呵 展开
2个回答
展开全部
Function UTF(ZZF)
Dim ZTEP, I, ZA, ZC
UTF = ""
ZTEP = ZZF & ""
If ZTEP = "" Then Exit Function
For I = 1 To Len(ZTEP)
ZA = Mid(ZTEP, I, 1)
ZC = Asc(ZA)
If ZC > 127 Or ZC < 0 Then
ZC = AscW(ZA)
If ZC < 0 Then ZC = &H10000 + ZC
If ZC < 2048 Then
UTF = UTF & "=" & Hex(((ZC \ &H40) And &H1F) Or &HC0) & "=" & Hex((ZC And &H3F) Or &H80)
Else
UTF = UTF & "=" & Hex(((ZC \ &H1000) And &HF) Or &HE0) & "=" & Hex(((ZC \ &H40) And &H3F) Or &H80) & "=" & Hex((ZC And &H3F) + &H80)
End If
Else
UTF = UTF & ZA
End If
Next I
End Function
Dim ZTEP, I, ZA, ZC
UTF = ""
ZTEP = ZZF & ""
If ZTEP = "" Then Exit Function
For I = 1 To Len(ZTEP)
ZA = Mid(ZTEP, I, 1)
ZC = Asc(ZA)
If ZC > 127 Or ZC < 0 Then
ZC = AscW(ZA)
If ZC < 0 Then ZC = &H10000 + ZC
If ZC < 2048 Then
UTF = UTF & "=" & Hex(((ZC \ &H40) And &H1F) Or &HC0) & "=" & Hex((ZC And &H3F) Or &H80)
Else
UTF = UTF & "=" & Hex(((ZC \ &H1000) And &HF) Or &HE0) & "=" & Hex(((ZC \ &H40) And &H3F) Or &H80) & "=" & Hex((ZC And &H3F) + &H80)
End If
Else
UTF = UTF & ZA
End If
Next I
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询