ASP / VBScript ServerXmlHttp Encoding

I pull the 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 should be encoding problems somewhere along the line, as I see ???? where some Japanese characters should be. Does anyone have any recommendations when working with ServerXmlHttp?

Thank.

+3
source share
3 answers

There are several possible problems.

  • What is the encoding and encoding used by your ASP page?

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

  1. What is an XML file encoding?

ASP , - , UTF-8 (CodePage 65001).

+2

:

:

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

When viewed on an unstructured web page, the browser may not use the correct encoding.

When XML is loaded into a parser, such as XMLDOM, the encoding must be respected and displayed correctly.

See XML coding for more details .

0
source

Source: https://habr.com/ru/post/1737558/


All Articles