CC: | KAPPA [...] cpan.org, makamaka [...] cpan.org |
Subject: | Template::Stash::XS is broken to deal with UTF-8 |
Template::Stash::XS cannot properly handle UTF-8 strings: it doesn't
work with UTF-8 hash keys at all. This bug relates to #45017 and #43323.
As a workaround you can say Template to use Template::Stash instead of
its XS-version:
$Template::Config::STASH = 'Template::Stash';
The complete proof and workaround demonstration:
use strict;
use warnings;
use utf8;
use Template;
binmode STDOUT, ':utf8';
# XXX: uncomment this to make Template work properly
#$Template::Config::STASH = 'Template::Stash';
Template->new()->process(\*DATA, {
ascii => 'key',
utf8 => 'ключ',
hash => {
key => 'value',
ключ => 'значение'
},
str => 'щука'
});
__DATA__
ascii = [% ascii %]
hash.$ascii = [% hash.$ascii %]
utf8 = [% utf8 %]
hash.$utf8 = [% hash.$utf8 %]
str.length = [% str.length %]