Subject: | XML::RSS outputs invalid UTF-8 code due to entity mapping. |
The entity conversion done in encode breaks the resulting XML stream after two passes if its encoding is not ISO-8859-1. The XML::Parser will choke with
a 'not well-formed (invalid token)' error.
Included code snippet reproduces the problem.
I do not see the added value of this entity to ISO-8859-1 character code entity conversion.
Mathias.
#!/usr/bin/perl -w
use XML::RSS;
$RSSFile = "/tmp/xml-rss-bug.rss";
#
# Create RSS Object.
#
my $rss = new XML::RSS (version => '1.0', encoding => 'iso-8859-1', output => '1.0');
#
# Add a channel
#
$rss->channel (title => "Channel Title",
link => "http://channel.url/",
description => "Channel Description");
#
# Add an item with accented characters
#
$rss->add_item (title => "Item Title",
link => "http://item.url/",
description => "Item Description (©)");
#
# Save RSS content to file.
#
open (RSS, ">$RSSFile") || die "Unable to open $RSSFile.";
print RSS $rss->as_string;
close (RSS);
#
# Now read it back in
#
$rss = new XML::RSS;
$rss->parsefile($RSSFile);
print "We read it OK this time...\n";
#
# save it again
#
open (RSS, ">$RSSFile") || die "Unable to open $RSSFile.";
print RSS $rss->as_string;
close (RSS);
#
# And read it back in again.
#
$rss = new XML::RSS;
$rss->parsefile($RSSFile);
print "But not this time :-(\n";