[Templates] Plugins and Unicode confusion
Bernhard Graf
tt@augensalat.de
Thu, 16 Feb 2006 21:27:20 +0100
I got this reply by PM - think it is OK to post it on the list:
> On 2/16/06, Bernhard Graf <tt@augensalat.de> wrote:
> > I have templates (and code) in UTF-8 encoded files.
> > Everything works fine until a plugin or an object expands non-ascii
> > strings into the template file: They are written as latin1!
> >
> > Here is an example:
> > Template file called "tt.tt" in current directory (UTF-8 encoded):
> >
> > [% USE date(locale =3D 'de_DE', format =3D '%B') -%]
> > N=E4chster Monat: [% date.format('00:00:00 01-03-2006') %]
>
> If you're sure that date.format returns the string in latin-1, you
> can pass a custom filter that converts latin-1 into utf-8, like:
Well I'm not sure, because strftime does return for the right encoding.
The basic problem for me (and probably others) is, that I don't=20
understand the magic inside Perl's unicode support enough (which is=20
described in many different manpages like perluniintro, encoding(3pm),=20
perlunicode, Encode, utf8, and others).
>
> FILTERS =3D> {
> l2u =3D> sub { Encode::from_to($_[0], 'latin-1' =3D> 'utf-8');
> $_[0] }, },
>
> [% date.format(...) | l2u %]
OK, that works.
But this is nontrivial.
Why does the expansion into UTF-8 (and maybe other encodings) fail, when=20
all components on their do it right?
=2D-=20
Bernhard Graf