Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP/VBScript ServerXmlHttp Encoding

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.

like image 246
Colin Ramsay Avatar asked Jul 15 '26 16:07

Colin Ramsay


2 Answers

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 
%>
like image 97
Francisco Campos Avatar answered Jul 19 '26 04:07

Francisco Campos


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).

like image 26
Thomas Kjørnes Avatar answered Jul 19 '26 03:07

Thomas Kjørnes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!