VB编程中如何将UTF-8和Unicode互相转换?
本人相菜鸟,希望注释下哦,还有用法。
VB编程中如何将UTF-8编码和Unicode编码互相转换?把UTF-8转码成Unicode的,和把UTF-8转成Unicode.....
追问:如果我想把wap网页的源码转成unicode格式的呢?我用这个方法获取的源码:Private Declare Function InternetOpen Lib "Wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "Wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetReadFile Lib "Wininet.dll" (ByVal hFile As Long, sBuffer As Any, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "Wininet.dll" (ByVal hInet As Long) As Integer
Private Const OnceLen = 2048
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const INTERNET_FLAG_RELOAD = &H80000000
Dim sq As StringDim p As String
'打开URL函数
Function OpenURL(ByVal sURL As String) As String
Dim hOpen As Long, hFile As Long, RetLen As Long, Buffer() As Byte, szBuffer As String
hOpen = InternetOpen(vbNullString, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
If hFile <> 0 Then
Do
ReDim Buffer(OnceLen - 1)
InternetReadFile hFile, ByVal VarPtr(Buffer(0)), OnceLen, RetLen
DoEvents
If RetLen = 0 Then Exit Do
If RetLen < OnceLen Then ReDim Preserve Buffer(RetLen - 1)
szBuffer = szBuffer & CStr(Buffer)
Loop
InternetCloseHandle hFile
End If
InternetCloseHandle hOpen
OpenURL = StrConv(szBuffer, vbUnicode)
End Function
Private Sub Form_Load()
p= OpenURL(" http://wap.zhaoxi.net")byt = Utf8ToUnicode(p)'这地方老是出问题,该怎么弄?就这个问题
End Sub