LWP::UserAgent and 8bit characters

Discussion in 'Perl Misc' started by T Conti, Sep 7, 2004.

  1. T Conti

    T Conti Guest

    Hello:

    I am using LWP::UserAgent to make a vanilla request to a web service.
    The return value is an XML file that may contain utf-8 characters.
    However when I debug my module I see that the return test is getting
    mangled. I can call the web service from IE and everything works
    fine. Here is the code I am using to make the HTTP call:

    my $ua = new LWP::UserAgent;
    my $request = new HTTP::Request('GET', $queryURL);
    my $response = $ua->request($request);
    my $string = $response->content;

    The resulting string slams umlates among other things. Here is a
    sample of the garbled return data:

    <Location>DE-Baden W├╝rttemberg-76137 Karlsruhe</Location>

    The proper return data should be:
    <Location>DE-Baden Württemberg-Obersontheim</Location>

    The return XML is utf-8 encoded. The headers of the response object
    seem to reflect this:

    $VAR1 = bless( {
    'client-response-num' => '1',
    'x-aspnet-version' => '1.1.4322',
    'content-type' => 'text/xml; charset=utf-8',
    'connection' => 'close',
    'date' => 'Tue, 07 Sep 2004 20:54:00 GMT',
    'server' => 'Microsoft-IIS/5.0',
    'client-date' => 'Tue, 07 Sep 2004 20:54:00 GMT',
    'content-length' => '18835',
    'cache-control' => 'private',
    'x-powered-by' => 'ASP.NET'
    }, 'HTTP::Headers' );


    Any thoughts on how to handle this?

    Thanks,
    T
     
    T Conti, Sep 7, 2004
    #1
    1. Advertising

  2. T Conti

    T Conti Guest

    I have been digging further and I found that the result from
    LWP::UserAgent is not the issue. The issue is further along the
    process after the return XML is parsed. It looks like the encoding
    gets all screwed up. I also found that I can write umlates to an html
    file, but the get slammed when they are rendered.

    (T Conti) wrote in message news:<>...
    > Hello:
    >
    > I am using LWP::UserAgent to make a vanilla request to a web service.
    > The return value is an XML file that may contain utf-8 characters.
    > However when I debug my module I see that the return test is getting
    > mangled. I can call the web service from IE and everything works
    > fine. Here is the code I am using to make the HTTP call:
    >
    > my $ua = new LWP::UserAgent;
    > my $request = new HTTP::Request('GET', $queryURL);
    > my $response = $ua->request($request);
    > my $string = $response->content;
    >
    > The resulting string slams umlates among other things. Here is a
    > sample of the garbled return data:
    >
    > <Location>DE-Baden W├╝rttemberg-76137 Karlsruhe</Location>
    >
    > The proper return data should be:
    > <Location>DE-Baden Württemberg-Obersontheim</Location>
    >
    > The return XML is utf-8 encoded. The headers of the response object
    > seem to reflect this:
    >
    > $VAR1 = bless( {
    > 'client-response-num' => '1',
    > 'x-aspnet-version' => '1.1.4322',
    > 'content-type' => 'text/xml; charset=utf-8',
    > 'connection' => 'close',
    > 'date' => 'Tue, 07 Sep 2004 20:54:00 GMT',
    > 'server' => 'Microsoft-IIS/5.0',
    > 'client-date' => 'Tue, 07 Sep 2004 20:54:00 GMT',
    > 'content-length' => '18835',
    > 'cache-control' => 'private',
    > 'x-powered-by' => 'ASP.NET'
    > }, 'HTTP::Headers' );
    >
    >
    > Any thoughts on how to handle this?
    >
    > Thanks,
    > T
     
    T Conti, Sep 8, 2004
    #2
    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. La Jesus
    Replies:
    9
    Views:
    1,354
    Gunnar Hjalmarsson
    Oct 27, 2003
  2. humble
    Replies:
    0
    Views:
    912
    humble
    Oct 28, 2006
  3. Paul Lemmons

    LWP::UserAgent and SSL is it impossible?

    Paul Lemmons, Nov 11, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    188
    Pierre Asselin
    Nov 12, 2003
  4. dan baker
    Replies:
    0
    Views:
    117
    dan baker
    Jan 18, 2004
  5. Thomas Kratz

    LWP::UserAgent and basic authentication

    Thomas Kratz, Apr 13, 2005, in forum: Perl Misc
    Replies:
    4
    Views:
    243
    Thomas Kratz
    Apr 14, 2005
Loading...

Share This Page