in reply to Re^2: UTF in Perl
in thread UTF in Perl
my code(snippet) looks like thisuse XML::SMART;
Where did you get XML::SMART from? I can't find that on cpan, only XML::Smart.
The XML seems to be valid with utf8 encoding.
Funny, when I run your script it prints the ä in Latin-1, which is a bug in the module (IMHO).
This works for me (ie produces a valid utf-8 XML file) (source file stored in UTF-8):
use XML::Smart; use Encode; my $XML = XML::Smart->new(q`<?xml version="1.0" encoding="UTF-8" ?> <MSR-ISSUE xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan +ce" xsi:noNamespaceSchemaLocation="my.xsd"> </MSR-ISSUE>`, 'XML::Smart::Parser'); my $test_in_incoming_xml = "Auch wenn man es nach Jahren guter Beschäf +tigung kaum verstehen kann"; utf8::upgrade($test_in_incoming_xml); $XML->{'MSR-ISSUE'}{'SHORT-NAME'}->content(0,$test_in_incoming_xml); my $xmlfile = "foo.xml"; $XML->save($xmlfile, nometagen => 1, forceutf8 => 1);
I'm pretty sure that the utf8::upgrade line is fundamentally wrong, and compensates for a XML::Smart bug.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: UTF in Perl
by KarthikK (Sexton) on Oct 10, 2008 at 14:56 UTC | |
by moritz (Cardinal) on Oct 10, 2008 at 15:07 UTC | |
by KarthikK (Sexton) on Oct 13, 2008 at 07:16 UTC |