in reply to Re: XML encoding problem
in thread XML encoding problem

I am not sure what I will do, but this gave me something to work with.
I created a small sub that converts the XML string to latin1 (which is the same as iso-8859-1??? or...)
use Unicode::String qw(utf8 latin1); sub utf8_to_latin1 { # get arguments my ($s1) = @_; # create a utf8 string with initial value of s1 # strange! it should already be in utf8 my $utf8 = Unicode::String->new( $s1 ); # convert to latin1 my $s2 = Unicode::String::latin1($utf8); return $s2; }
but I don't understand why I have to create a new utf8 string, when the XML string should already be in utf8?

Replies are listed 'Best First'.
Re^3: XML encoding problem
by wazoox (Prior) on Mar 15, 2006 at 11:17 UTC

    You're simply creating an object, you don't actually need it to pass the string to it. Use Unicode::String->stringify_as('latin1'); instead, see Unicode::String documentation :

    $us = Unicode::String->new( $initial_value )
    (...)
    In general it is recommended to import and use one of the encoding specific constructor functions instead of invoking this method.