Gisle_Aas via RT wrote 130 bytes:
Show quoted text
See below. With parse_head => 1 the in-html encoding of cp1250 overrides
the server-sent utf8, albeit the page content is in utf8.
The server-sent header should take precedence (see previous mail).
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use Encode qw/decode/;
for my $hdr (qw/0 1/) {
print "Parse head: $hdr\n";
my $agent = LWP::UserAgent->new(parse_head => $hdr);
my $reply = $agent->get('
http://www.iprima.cz');
my $cp1250 = decode('cp1250', $reply->content);
my $utf = decode('utf-8', $reply->content);
my $lwp = $reply->decoded_content;
print join('|', $reply->header('Content-Type')), "\n";
print "cp1250: ", $lwp cmp $cp1250, "\n";
print "utf-8: ", $lwp cmp $utf, "\n";
}