3

我正在使用 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 时有任何指导吗?

谢谢。

4

3 回答 3

4

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

不工作:

<%@ 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 
%>
于 2011-02-19T20:00:10.533 回答
2

这里有几个可能的问题。

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

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

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

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

于 2010-04-14T18:04:52.863 回答
0

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

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

有关更多信息,请参阅XML 编码

于 2010-03-18T17:39:58.110 回答