gregorovius has asked for the wisdom of the Perl Monks concerning the following question:
Note that if I converted the $utf8_from_xml_rss variable to latin1 the print statement would work fine.
This almost caused me a headache last week when a client in a different continent and behind a firewall was reporting that a program my company supplied was printing gibberish, and we couldn't reproduce it.
The output produced by the program follows right after it.
#!/usr/bin/perl -w use strict; use Unicode::String; use XML::RSS; my $latin1 = "Größter Anstieg seit März 1998"; my $utf8 = Unicode::String::latin1( $latin1 )->utf8; print "1: $utf8 - $latin1 \n"; my $rss_content = <<'EOF'; <?xml version="1.0" encoding="ISO-8859-1" ?><rss version="0.91"><chann +el><item> <title>Größter Anstieg seit März 1998</title></item></ch +annel></rss> EOF my $rss = new XML::RSS; $rss->parse( $rss_content ); foreach my $item ( @{ $rss->{items} } ) { # XML::RSS always returns its findings in UTF8 my $utf8_from_xml_rss = $item->{title}; print "2: $utf8_from_xml_rss - $latin1 \n"; } # under Perl 5.6.0 and earlier the output is: # 1: GröÃter Anstieg seit März 1998 - Größter Anstieg seit März 1998 + # 2: GröÃter Anstieg seit März 1998 - Größter Anstieg seit März 1998 + # under Perl 5.6.1 the output is # 1: GröÃter Anstieg seit März 1998 - Größter Anstieg seit März 1998 + # 2: GröÃter Anstieg seit März 1998 - GröÃter Anstieg seit März 19 +98
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Bug in Perl 5.6.1 ?
by jlongino (Parson) on Dec 08, 2001 at 23:40 UTC | |
by gregorovius (Friar) on Dec 09, 2001 at 00:17 UTC | |
Re: Bug in Perl 5.6.1 ?
by dws (Chancellor) on Dec 08, 2001 at 22:29 UTC | |
by gregorovius (Friar) on Dec 09, 2001 at 00:00 UTC |