WinHttp适用于UTF-8但不适用于utf-8
我正在使用VBA代码中的WinHttp,它适用于返回"Content-type text / html; UTF-8"的网站,例如
www.kth.se 。但对于具有"Content-type text / html; utf-8"的网站,例如
www.svd.se ,  ;它根本不起作用。显然WinHttp在小写时说utf-8时无法识别内容类型。这里发生了什么?
I'm using WinHttp from VBA code and it works just fine for sites returning "Content-type text/html;UTF-8", like www.kth.se. But for sites with "Content-type text/html;utf-8", like www.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
对我来说工作正常! 定义'它根本不起作用'?
Works fine for me! Define 'it doesn't work at all'?
在调试器中运行它并检查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.