ASP/VBScript ServerXmlHttp 编码

发布于 2024-08-26 02:21:40 字数 362 浏览 10 评论 0原文

我正在使用 ServerXmlHttp 从远程位置提取 RSS 提要:

Dim httpRequest
set httpRequest = server.createObject("Msxml2.ServerXMLHTTP.6.0")
httpRequest.open "GET", "http://www.someurl.com/feed.xml", false
httpRequest.send()
response.write httpRequest.responseXML.xml

但是,正如我所见,沿线某处一定存在编码问题???应该有一些日语字符的地方。使用 ServerXmlHttp 时有人有任何指导吗?

谢谢。

I'm pulling an RSS feed from a remote location using ServerXmlHttp:

Dim httpRequest
set httpRequest = server.createObject("Msxml2.ServerXMLHTTP.6.0")
httpRequest.open "GET", "http://www.someurl.com/feed.xml", false
httpRequest.send()
response.write httpRequest.responseXML.xml

However there must be encoding issues somewhere along the line as I'm seeing ???? where there should be some Japanese characters. Does anyone have any guidance when working with ServerXmlHttp?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

枕梦 2024-09-02 02:21:40

经过几个小时的调查,这些是我的结果:

不起作用:

<%@ Language=VBScript Codepage=65001 %>

它显示的不是正确的特殊字符,而是问号黑色问号。

但这有效!

Response.CodePage = 65001

我还包括了

Response.Charset = "UTF-8"
response.AddHeader "Content-Type", "text/html;charset=UTF-8"

最终结果:

<%@ Language=VBScript %>
<%
Dim xmlhttp
Set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP")

xmlhttp.open "GET", "http://www.sapo.pt", 0
xmlhttp.send ""
Dim pagina

response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.Charset = "UTF-8"


pagina = xmlhttp.responseText
Response.Write pagina
Set xmlhttp = Nothing 
%>

After some hours of investigation, these are my results:

Does not work:

<%@ Language=VBScript Codepage=65001 %>

And instead of correct special chars, it shows question marks black question marks.

But this works!!

Response.CodePage = 65001

I've also included

Response.Charset = "UTF-8"
response.AddHeader "Content-Type", "text/html;charset=UTF-8"

Final result:

<%@ Language=VBScript %>
<%
Dim xmlhttp
Set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP")

xmlhttp.open "GET", "http://www.sapo.pt", 0
xmlhttp.send ""
Dim pagina

response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.Charset = "UTF-8"


pagina = xmlhttp.responseText
Response.Write pagina
Set xmlhttp = Nothing 
%>
旧街凉风 2024-09-02 02:21:40

这里有几个可能的问题。

  1. 您的 ASP 页面使用的代码页和字符集是什么?

这可以使用 <%@ CodePage=xxxxx %> 设置指令或 Response.CodePage 和 Response.Charset。

  1. XML 文件的编码是什么?

众所周知,经典 ASP 对这些东西的支持很差,最安全的选择是坚持使用单一编码,最好是 UTF-8 (CodePage 65001)。

There are several possible issues here.

  1. What is the codepage and charset used by your ASP page?

This can either be set with the <%@ CodePage=xxxxx %> directive or Response.CodePage and Response.Charset.

  1. What is the encoding of th XML-file?

Classic ASP has notoriously bad support for these things, and the safest bet is to stick with a single encoding, preferably UTF-8 (CodePage 65001).

岁月打碎记忆 2024-09-02 02:21:40

在非结构化网页中查看时,浏览器可能未使用正确的编码。

当 XML 被加载到像 XMLDOM 这样的解析器中时,应该尊重编码并正确显示。

有关详细信息,请参阅XML 编码

When viewing in an unstructured web page, the browser may not be using the correct encoding.

When the XML is loaded into a parser like XMLDOM, the encoding should be respected and displayed correctly.

See XML Encoding for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文