vb winhttp post 返回的数据 含有中文的部分是乱码,怎么解决?
发布网友
发布时间:2022-05-14 19:09
我来回答
共2个回答
热心网友
时间:2022-06-25 21:01
Set xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1") 'Createobject("MSXML2.xmlhttp.6.0")
'MsgBox TypeName(xmlhttp)
xmlhttp.open "GET","http://ajjl.cn/"
xmlhttp.setRequestHeader "Pragma","no-cache"
xmlhttp.setRequestHeader "Cache-Control","no-cache"
xmlhttp.send
xmlhttp.WaitForResponse
MsgBox BytesToBstr(xmlhttp.ResponseBody,"utf-8")
Function BytesToBstr(Body, Cset)
On Error Resume Next
'"GB2312"
'"GBK"
'"UTF-8"
Dim Objstream
Set Objstream = CreateObject("adodb.stream")
Objstream.Type = 1
Objstream.Mode = 3
Objstream.Open
Objstream.Write Body
Objstream.Position = 0
Objstream.Type = 2
Objstream.Charset = Cset
BytesToBstr = Objstream.ReadText
Objstream.Close
Set Objstream = Nothing
End Function
热心网友
时间:2022-06-25 21:02
应该是要转码,你看一下你请求的网站用的是什么编码,再适当的调整一下,你这样我也不太清除是什么情况