in reply to Re: UTF8 and XML
in thread UTF8 and XML

So if i wanted to send ISO-8859-1 xml i would just add that to the header? Doing this didnt make a difference. Please see

#!/usr/bin/perl use strict; use utf8; # A simple test to show the UTF8 problem my $parameters; push (@{ $parameters->{Request} }, { URI => '/HRM/EmploymentManager/AvailableOpening +s', Action => 'GET', ID => '123', Parameters => { Status => 'Test', }, }); # convert Perl hash ref into XML my $xs = XML::Simple->new(); my $x = $xs->XMLout($parameters, KeepRoot => 0, RootName => 'Requests' +,XMLDecl => qq{<?xml version="1.0" encoding="iso-8859-1"?>}); print $x; # convert XML into Perl hash ref my $xs = XML::Simple->new(); my $XML = $xs->XMLin($x,ForceArray => 0); # Look at the perl hash ref, there shouldnt be any my $temp = $XML->{'Request'}->{'Action'}; my $flag = utf8::is_utf8($temp); print "$flag ! $temp\n\n\n"; exit;

Replies are listed 'Best First'.
Re^3: UTF8 and XML
by ikegami (Patriarch) on Mar 09, 2010 at 05:21 UTC

    No, you removed the encoding. While XML::Simple properly decodes when parsing XML, it doesn't encode when generating XML. (That's a bug. I called it a "weird interface" earlier.)