WinHttp适用于UTF-8但不适用于utf-8 [英] WinHttp works fine with UTF-8 but not with utf-8

查看:115
本文介绍了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.


这篇关于WinHttp适用于UTF-8但不适用于utf-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆