Re: [Templates] Hashes: issue with UTF-8 keys
[prev]
[thread]
[next]
[Date index for 2004/10/28]
On Wed, 2004-10-20 at 08:23, Dave Meibusch wrote:
> Hi,
> I've found an issue with hashes when a key is a UTF-8 string.
> I have some simple test code:
>=20
> #!/usr/bin/env perl
> use strict;
> use Template;
> my $tt =3D Template->new({ INCLUDE_PATH =3D> '.', }) || die
> "$Template::ERROR\n";
> my %hash =3D ( 'good' =3D> 1234, "bad \x{20AC}" =3D> 4321, );
> my $vars =3D {
> hash =3D> \%hash,
> };
> $tt->process('template.tt', $vars) || die $tt->error(), "\n";
>=20
>=20
> template.txt:
> Start [% component.name %]
> Iterate through the hash:
>=20
> [% FOREACH key =3D hash.keys %]
> Key: [% key %] Exists: [% hash.exists(key) %] Value: [% hash.$key=
%]
> Item: [% hash.item(key) %]
> [% END %]
>=20
> End [% component.name %]
>=20
>=20
> With both TT 2.13 and 2.14 the output is:
>=20
> Start template.tt
> Iterate through the hash:
>=20
> Key: good Exists: 1 Value: 1234 Item: 1234
>=20
> Key: bad =E2=AC Exists: 1 Value: Item: 4321
>=20
> End template.tt
>=20
> Note that [% hash.$key %] fails for the UTF-8 key, but [% hash.item(key) =
%]
> works (and is a workaround).
>=20
> This is with Perl 5.8.4. Maybe someone can confirm it isn't a Perl proble=
m
> with a more recent version?
>=20
I guess this is just a problem with the XS stash.
Regards,
Slaven
--=20
Slaven Rezic > Development
iconmobile GmbH > Methfesselstr. 32-36 > D-10965 Berlin
phone +49 30 890 686 49 > fax +49 30 890 686 50
srezic@xxxxxxxxxx.xxx > http://www.iconmobile.com
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] Hashes: issue with UTF-8 keys
Slaven Rezic 10:29 on 28 Oct 2004
|