ServerXMLHTTP and question marks Problem

Discussion in 'ASP General' started by Dana, Nov 10, 2005.

  1. Dana

    Dana Guest

    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
     
    Dana, Nov 10, 2005
    #1
    1. Advertising

  2. Dana wrote:

    > 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


    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
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Nov 10, 2005
    #2
    1. Advertising

  3. Dana

    Dana Guest

    Thank for the reply.

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



    Dana


    "Martin Honnen" <> wrote in message
    news:%...
    >
    >
    > Dana wrote:
    >
    >> 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

    >
    > 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
    > http://JavaScript.FAQTs.com/
     
    Dana, Nov 11, 2005
    #3
  4. "Dana" <> wrote in message
    news:...
    >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!!


    This is because

    <% @codepage=65001%>
    should be set as well.
     
    Egbert Nierop \(MVP for IIS\), Nov 11, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bülent Keskin
    Replies:
    1
    Views:
    628
    Guy Soffer
    Aug 10, 2003
  2. katrinaVictim@.

    msxml2.serverXMLhttp and response.binarywrite

    katrinaVictim@., Oct 16, 2005, in forum: ASP General
    Replies:
    4
    Views:
    337
    McKirahan
    Oct 17, 2005
  3. Jen
    Replies:
    1
    Views:
    204
  4. Lambuz

    ServerXMLHTTP and impersonation

    Lambuz, Dec 21, 2005, in forum: ASP General
    Replies:
    10
    Views:
    237
    Egbert Nierop \(MVP for IIS\)
    Jan 30, 2006
  5. Edwin Eyan Moragas

    nuby question: question marks in method names

    Edwin Eyan Moragas, Aug 30, 2004, in forum: Ruby
    Replies:
    0
    Views:
    152
    Edwin Eyan Moragas
    Aug 30, 2004
Loading...

Share This Page