ASP / VBScript ServerXmlHttp编码

时间:2010-03-18 16:47:19

标签: encoding asp-classic vbscript serverxmlhttp

我使用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时有没有人有任何指导?

感谢。

3 个答案:

答案 0 :(得分:3)

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

不起作用:

<%@ 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 
%>

答案 1 :(得分:2)

这里有几个可能的问题。

  1. ASP页面使用的代码页和字符集是什么?
  2. 可以使用&lt;%@ CodePage = xxxxx%&gt;设置此值。指令或Response.CodePage和Response.Charset。

    1. XML文件的编码是什么?
    2. 经典ASP对这些事情的支持非常糟糕,最安全的选择是坚持使用单一编码,最好是UTF-8(CodePage 65001)。

答案 2 :(得分:0)

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

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

有关详细信息,请参阅XML Encoding

相关问题