[Petal] More problems with UTF-8
Michele Beltrame
mb at italpro.net
Wed Jun 9 19:17:58 BST 2004
Hi all!
I'm experiencing some more problems with charsets. I subclassed Petal's
process() to always output UTF-8:
package Petal::AlwaysUTF8;
use strict;
use base qw /Petal/;
use Encode;
sub process
{
my $self = shift;
my $res = $self->SUPER::process (@_);
return Encode::encode ('utf8', $res);
}
This works just fine as all entities on the templates get correctly
( à, , ...) get correctly converted to UTF-8.
The problem arises with UTF-8 data which is inserted into the template at
runtime (from the script, data I get from the database). This data is
already UTF-8 and it seems it gets converted again by my subclassed
process() method, which of course leads to weird display.
I tried:
use encoding 'utf8';
The results are a mess: if I don't use my subclassed process() method
everything appears nice, except for entities of the template ( ...);
if I use the subclassed method, then everything gets encoded twice and
the result is something impossible to describe. ;-)
I guess that what I need to do is ensure that the template is UTF-8
(maybe by using Encode), but this should probably happen before the
insertion of the data ( process() ), as that data is already UTF-8!
I tried, without any success, to mix the decode_charset setting of
Petal with all what I described above.
Any suggestion?
Thank you in advance, Michele.
--
Michele Beltrame
http://www.italpro.net/mb/
ICQ# 76660101 - e-mail: mb at italpro.net
More information about the Petal
mailing list