问题描述
我正在使用VBA代码中的WinHttp,它适用于返回"Content-type text / html; UTF-8"的网站,例如
www.kth.se 。但对于具有"Content-type text / html; utf-8"的网站,例如
,  ;它根本不起作用。显然WinHttp在小写时说utf-8时无法识别内容类型。这里发生了什么?
I'm using WinHttp from VBA code and it works just fine for sites returning "Content-type text/html;UTF-8", likewww.kth.se. But for sites with "Content-type text/html;utf-8", likewww.svd.se, it doesn't work at all. Apparently WinHttp fails to recognize the content type when it says utf-8 in lower case. What is going on here?
/ Må ns
/Måns
推荐答案
在调试器中运行它并检查aRequest.response.Text:
run this in the debugger and inspect aRequest.response.Text:
wscript.exe / / x // d test.vbs
wscript.exe //x //d test.vbs
Test.vbs:
Dim aRequest
set aRequest = CreateObject(" WinHttp.WinHttpRequest.5.1")
aRequest.Open" GET"," http://www.svd.se/",False
aRequest.Send
Wscript.Echo aRequest.responseText
Dim aRequest
set aRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
aRequest.Open "GET","http://www.svd.se/",False
aRequest.Send
Wscript.Echo aRequest.responseText
您将在本地窗口中看到输出对于该网站。
You will see output in the locals window for that site.
Wscript.Echo存在问题,但这可能是由于返回了无效的字符集。
There is an issue with Wscript.Echo but that is probably due to an invalid charset being returned.
这篇关于WinHttp适用于UTF-8但不适用于utf-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!