http://qs321.pair.com?node_id=1125097

Transalp has asked for the wisdom of the Perl Monks concerning the following question:

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>