[Petal] Petal / UTF-8-ness

Grant McLean grant at mclean.net.nz
Fri Jun 27 07:58:02 BST 2003


Jean-Michel Hiver wrote:
> $Petal::DECODE = <some_charset>;
> $Petal::ENCODE = <some_charset>;
> 
> (with the associated constructor options for the 'everything should
> always be an object' freaks)

Hey, I resemble that remark!

> Where $Petal::DECODE is the character set that your templates are in and
> $Petal::ENCODE is the character set that you want your output to be in.

> What do you guys think?

I think you could be buying yourself a hatload of trouble :-)

I'm not sure what sort of problems you're having with UTF-8 but the
things I'd see as important are:

  * input from a UTF-8 template should work
  * output should default to UTF-8
  * during template processing any variables users pass to Petal should
    be UTF-8

On the input side if templates are XML/XHTML and specify a different
encoding then the parser should be converting it to UTF-8 for you.

On the output side, if the result is destined for a browser then
leaving it in UTF-8 should work with any sane browser (certainly works
with all the main ones).  If the output is going to something that
requires a non-UTF-8 encoding then there are tools (such as iconv) to
recode streams.

I don't have any problem with encoding translations being added to
Petal as an option but without knowing the details of problem you're 
having then I also don't see a need.

Regards
Grant





More information about the Petal mailing list