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 = ( 'http://www.ranks.nl/images/test/intrend4kids.htm', 'http://www.readyplanet.com/', ); 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

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.