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

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

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

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:
    718
    Guy Soffer
    Aug 10, 2003
  2. J-T
    Replies:
    0
    Views:
    553
  3. Elhanan
    Replies:
    17
    Views:
    1,242
    Elhanan
    Dec 17, 2005
  4. Swetha
    Replies:
    16
    Views:
    8,448
    Roedy Green
    Dec 13, 2005
  5. Peng Yu

    Question about concatenating quotation marks

    Peng Yu, Oct 1, 2004, in forum: C Programming
    Replies:
    3
    Views:
    433
    Mark McIntyre
    Oct 2, 2004
  6. el-sherif
    Replies:
    0
    Views:
    189
    el-sherif
    Jul 24, 2003
  7. Edwin Eyan Moragas

    nuby question: question marks in method names

    Edwin Eyan Moragas, Aug 30, 2004, in forum: Ruby
    Replies:
    0
    Views:
    245
    Edwin Eyan Moragas
    Aug 30, 2004
  8. Matt Smith
    Replies:
    3
    Views:
    291
    Matt Smith
    Oct 6, 2005
Loading...