Subject: | saving xml file changes encoding |
Date: | Fri, 23 Apr 2010 23:53:57 +0200 |
To: | bug-XML-RSS [...] rt.cpan.org |
From: | Steffen Wirth <s.wirth [...] lnx-support.de> |
Hi,
when I am using XML:RSS (version 1.47 or 1.48) to create a xml file my
Japanese characters are not shown correctly.
The script reads information from a sqlite database and then I want to
create the file. The encoding in the database and when I read
information from the database the characters are shown correctly (e.g.
メール) but when I add a new item then it is now shown correctly.
e.g
#!/usr/bin/perl
use utf8;
use XML::RSS;
use Encode qw/encode decode/;
my $name="メール";
my $title="どこでも";
print "$name ----- $title\n";
my $rss = XML::RSS->new(version=>'2.0');
$rss->channel(
title => "$name",
link => "http://link.com",
language => "ja",
description => "$name",
pubDate => 'Thu, 23 Aug 1999 07:00:00 GMT',
lastBuildDate => 'Thu, 23 Aug 1999 16:20:26 GMT',
);
my $check = utf8::valid($name);
print "is utf valild?: $check\n";
$rss->add_item(title => "$name",
link => "http://link.com",
mode => 'insert'
);
print $rss->as_string;
$rss->save("test.xml");
# EOF
and the result is ->
perl test.pl
Wide character in print at test.pl line 12.
メール ----- どこでも
is utf valild?: 1
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
Show quoted text
>
<channel>
<title>メール</title>
<link>http://link.com</link>
<description>メール</description>
<language>ja</language>
<pubDate>Thu, 23 Aug 1999 07:00:00 GMT</pubDate>
<lastBuildDate>Thu, 23 Aug 1999 16:20:26 GMT</lastBuildDate>
<item>
<title>メール</title>
<link>http://link.com</link>
</item>
</channel>
</rss>
# EOF
any idea or suggestions?
Thanks.
Steffen