Subject: | $XML::Atom::ForceUnicode does nothing? |
Date: | Wed, 8 Apr 2015 16:15:47 -0700 |
To: | bug-XML-Atom [...] rt.cpan.org |
From: | John SJ Anderson <genehack [...] genehack.org> |
Seems as if regardless of whether this flag is set, if data has multibyte
characters in it, it must be explicitly decoded before output. The code
below generates the exact same output for the two calls to 'write_feed',
despite the flag being flipped on between the two calls.
#! /usr/bin/env perl
use 5.014; # strict, unicode_strings
use warnings;
use utf8;
use autodie;
use warnings qw/ FATAL utf8 /;
use open qw/ :std :utf8 /;
use charnames qw/ :full /;
use Path::Tiny;
use XML::Atom;
use XML::Atom::Feed;
use XML::Atom::Entry;
write_feed( 'flag_off' );
$XML::Atom::ForceUnicode = 1;
write_feed( 'flag_on' );
sub write_feed {
my $name = shift;
my $feed = XML::Atom::Feed->new;
$feed->title('My å Weblog');
$feed->id('tag:example.com,2006:feed-id');
my $entry = XML::Atom::Entry->new;
$entry->title('First å Post');
$entry->id('tag:example.com,2006:entry-id');
$entry->content('Post å Body');
$feed->add_entry($entry);
my $xml = $feed->as_xml;
path( $name )->spew( $xml );
}