Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi Monks,

I have a test script (below) that works well on one server, but not on two other servers. Does anyone have an idea what might cause this ?

The script below contains two test URLs in @tests using a Thai font. The content of both test URLs are reported to be in UTF8 according to the 'is_utf8' test after retrieval, but only one server prints the content of $body of both URLs in a readable format when run in a browser.

The other two servers print 'garbled' instead of Thai fonts for the first URL, but work fine on the second URL. When I manually set the browser to switch from Character Encoding Unicode to use 'Thai' instead on these two servers, the garbled Thai text does become readable.

The problematic first URL does contain a double content-type meta tag with different charsets in the HTML source, but this is appearently not an issue on the one server that does work well.

Next week the one server that is working well will be taken off line so I'm trying to find the difference between the servers as soon as possible.

All three servers use CentOS 6.6, Perl version v5.10.1 and LWP Bundle::LWP 5.810

Test script:
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Encode qw/ is_utf8 /; my $agent = LWP::UserAgent->new(); print "Content-type: text/html; charset=utf-8\n\n"; ##two websites using Thai fonts my @tests = ( '', '', ); foreach my $uri (@tests) { eval { printf "test: %s <br>", $uri; my $response = $agent->get($uri); my $dc = $response->decoded_content( raise_error => 1 ); printf "is decoded content utf8? %s <br>", is_utf8($dc); print qq~ <br> <textarea cols=80 rows=20>$dc</textarea> <br> ~; }; if ($@) { print "decode failed: $@\n"; } print "\n"; }

<Added>: the same problem occurs when I use curl instead of LWP </Added>

In reply to LWP $response->decoded_content different on different servers ? by Transalp

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2023-12-09 01:33 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (37 votes). Check out past polls.