Skip Menu |
 

This queue is for tickets about the XML-RSS CPAN distribution.

Report information
The Basics
Id: 56869
Status: rejected
Priority: 0/
Queue: XML-RSS

People
Owner: Nobody in particular
Requestors: s.wirth [...] lnx-support.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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>
Download (untitled) / with headers
text/plain 1.7k
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>&#x30E1;&#x30FC;&#x30EB;</title> <link>http://link.com</link> <description>&#x30E1;&#x30FC;&#x30EB;</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>&#x30E1;&#x30FC;&#x30EB;</title> <link>http://link.com</link> </item> </channel> </rss> # EOF any idea or suggestions? Thanks. Steffen
Download (untitled) / with headers
text/plain 2.5k
Hi Steffen, On Fri Apr 23 17:54:10 2010, s.wirth@lnx-support.de wrote: Show quoted text
> 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.
How are they not shown correctly? What is the difference between those you input and those that are displayed? I should note that I see these Japanese characters as squares here sometimes because I likely don't have a Japanese font. Show quoted text
> > 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.
Probably s/now/not/. Show quoted text
> > e.g > > #!/usr/bin/perl > > use utf8; > use XML::RSS;
Why didn't you add "use strict;" and "use warnings;"? Furthermore, is "use utf8;" enough to output UTF-8 to STDOUT? I think you also need << binmode STDOUT, ":encoding(utf8)"; >>. Show quoted text
> use Encode qw/encode decode/; > > > my $name="メール"; > my $title="どこでも"; > > > print "$name ----- $title\n"; > > my $rss = XML::RSS->new(version=>'2.0');
Did you set the encoding of the $rss? It's documented in the POD. Show quoted text
> $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"
> >
> > <channel> > <title>&#x30E1;&#x30FC;&#x30EB;</title> > <link>http://link.com</link> > <description>&#x30E1;&#x30FC;&#x30EB;</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>&#x30E1;&#x30FC;&#x30EB;</title> > <link>http://link.com</link> > </item> > </channel> > </rss> > > # EOF > > > any idea or suggestions? >
Maybe try setting the encoding. Regards, Shlomi Fish Show quoted text
> Thanks. > > Steffen > > >
Subject: Re: [rt.cpan.org #56869] saving xml file changes encoding
Date: Sun, 09 May 2010 13:59:33 +0200
To: bug-XML-RSS [...] rt.cpan.org
From: Steffen Wirth <s.wirth [...] lnx-support.de>
Download (untitled) / with headers
text/plain 2.9k
Hi Shlomi, you are right it was an encoding problem. I could fix it with "encode_output=>'0'". Thanks a lot. king regards Steffen On 04/26/2010 09:59 AM, Shlomi Fish via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=56869 > > > Hi Steffen, > > On Fri Apr 23 17:54:10 2010, s.wirth@lnx-support.de wrote:
>> 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.
> > How are they not shown correctly? What is the difference between those > you input and those that are displayed? > > I should note that I see these Japanese characters as squares here > sometimes because I likely don't have a Japanese font. >
>> >> 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.
> > Probably s/now/not/. >
>> >> e.g >> >> #!/usr/bin/perl >> >> use utf8; >> use XML::RSS;
> > Why didn't you add "use strict;" and "use warnings;"? > > Furthermore, is "use utf8;" enough to output UTF-8 to STDOUT? I think > you also need << binmode STDOUT, ":encoding(utf8)"; >>. >
>> use Encode qw/encode decode/; >> >> >> my $name="メール"; >> my $title="どこでも"; >> >> >> print "$name ----- $title\n"; >> >> my $rss = XML::RSS->new(version=>'2.0');
> > Did you set the encoding of the $rss? It's documented in the POD. >
>> $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"
>>>
>> >> <channel> >> <title>&#x30E1;&#x30FC;&#x30EB;</title> >> <link>http://link.com</link> >> <description>&#x30E1;&#x30FC;&#x30EB;</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>&#x30E1;&#x30FC;&#x30EB;</title> >> <link>http://link.com</link> >> </item> >> </channel> >> </rss> >> >> # EOF >> >> >> any idea or suggestions? >>
> > Maybe try setting the encoding. > > Regards, > > Shlomi Fish >
>> Thanks. >> >> Steffen >> >> >>
> > > >
Download (untitled) / with headers
text/plain 322b
Hi Steffen, On Sun May 09 07:59:53 2010, s.wirth@lnx-support.de wrote: Show quoted text
> Hi Shlomi, > > you are right it was an encoding problem. I could fix it with > "encode_output=>'0'". >
Nice. Show quoted text
> Thanks a lot.
You're welcome. I'm going to close this bug as "rejected". Regards, -- Shlomi Fish Show quoted text
> > king regards > > Steffen


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.