Groups | Blog | Home
all groups > inetserver asp general > november 2005 >

inetserver asp general : ServerXMLHTTP and question marks Problem


Dana
11/10/2005 11:36:09 AM
I am having a problem with the following code:

Response.CharSet = "UTF-8"
url = "http://www.domain.com/myisapi.dll"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "text/HTML"
xmlhttp.setRequestHeader "CharSet", "UTF-8"
xmlhttp.send "param=1"
txt = xmlhttp.responsetext

The request is sent properly to the page (myisapi.dll) but the returned
valued is not correct!!

Characters over 127 ascii, will be converted to question marks, even though
I changed the Response.CharSet

To test it, you can change the code to the following:

Response.CharSet = "UTF-8"
url="http://www.google.fr/"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.setRequestHeader "Content-Type", "text/HTML"
xmlhttp.setRequestHeader "CharSet", "UTF-8"
txt = xmlhttp.responsetext

You will see some question marks which got converted since they were over
127.

Any ideas!!!



Dana

Martin Honnen
11/10/2005 5:11:51 PM


[quoted text, click to view]

responseText with XMLHTTP and MSXML is not very helpful to receive the
response from an abritrary web page and decode it, it can and does deal
with Unicode encodings like UTF-8 but it does not decode any ISO-8859-x
encoding for instance, it assumes an Unicode encoding and only looks for
a BOM (byte order mark).
Documentations is here:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/b035fdea-8665-4d7b-80f0-3624d269e7b6.asp>

Depending on what you want to do it might be possible to use
responseBody or responseStream instead of responseText e.g. within ASP
Response.BinaryWrite xmlhttp.responseBody
might do to output the response body XMLHTTP received.



--

Martin Honnen --- MVP XML
Egbert Nierop (MVP for IIS)
11/11/2005 12:00:00 AM

[quoted text, click to view]

This is because

<% @codepage=65001%>
should be set as well.

Dana
11/11/2005 9:31:25 AM
Thank for the reply.

I managed to use the responseBody then convert it to a string value.



Dana


[quoted text, click to view]

AddThis Social Bookmark Button