I have this warning every time I run my CGI-script (output is rendered by Template::Toolkit):
Wide character in print at /usr/local/lib/perl5/site_perl/5.8.9/mach/Template.pm line 163. 
What's the right way to eliminate it?
I create the tt object using this config:
my %config = (
       ENCODING     => 'utf8',
       INCLUDE_PATH => $ENV{TEMPLATES_DIR},
       EVAL_PERL   => 1,
}
my $tt = Template->new(\%config); 
Put this before the call to $tt->process() to have the output automatically encoded: 
binmode STDOUT, ':utf8';
Edit: As daxim mentioned, it's possible to utilize TT's encoding facilities:
$tt->process($infile, $vars, '-', { binmode => ':utf8' })
This relies on the widely used convention that the '-' filename gives you STDIN when it's opened for reading, and STDOUT when it's opened for writing. 
Edit 2: BTW, the latter way doesn't seem to work for me under mod_perl (2.0.5).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With