in reply to Re: utf8 && XML::Simple
in thread utf8 && XML::Simple
returns:#!/usr/bin/perl use XML::Simple; use Data::Dumper; use Encode; my $content = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; $content .= "<tag>\x{c3}\x{bb}</tag>\n"; print "input:\n$content\n"; my $xml = new XML::Simple; my $data = $xml->XMLin($content, KeepRoot => 1); encode_utf8($data->{'tag'}); print "data: ".$data->{'tag'}."\n"; print Dumper $data;
input: <?xml version="1.0" encoding="UTF-8" ?> <tag>û</tag> data: $VAR1 = { 'tag' => "\x{fb}" };
My real life code tries to parse an xml with xml::Simple and stores the data in a mysql-database. The database has the same encoding problems as above.
I am looking at this sample code for days now with no idea where to go on ... Any help is appreciated!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: utf8 && XML::Simple
by Corion (Patriarch) on Apr 16, 2015 at 07:49 UTC | |
by Trace On (Novice) on Apr 16, 2015 at 14:15 UTC |