[Petal] entity euro hurts

Jean-Michel Hiver jhiver at mkdoc.com
Mon Apr 26 15:27:20 BST 2004


Michele Beltrame wrote:

>Hi Jean!
>
>  
>
>>In MKDoc/XML/Decode/XHTML.pm, euro points to the decimal value 8364. 
>>Since this is a unicode high value, Perl has to upgrade all your strings 
>>to unicode. Hence, whenever you use € symbol the resulting string 
>>will be UTF-8 rather than latin1.
>>    
>>
>
>Just a final question. As said, I now output UTF8 to the browser (setting
>the appropriate charset in the HTTP header and meta tag). This however
>works until the string (parsed template) I send is really UTF8, that
>it to say when I include something that produces an Unicode high value, such
>as "€". If I don't do this, Perl doesn't convert its strings to UTF8
>and they remain latin1.
>
>This behavious causes the browser (I use Mozilla Firefox under Linux/GTK) to
>work just fine if the string is really Unicode, but not that good if
>it's not. So, if I don't include an "€" in my template, " "
>charachters are shown as a square with FFDD inside (which means that
>Mozilla does not own a proper char to dislay).
>

You have to use the Encode module to make sure your data is always UTF-8.

use Encode;
my $string = $template->process (%stuff);
$string = Encode::encode ('utf8', $string);

Cheers,
Jean-Michel.



More information about the Petal mailing list