You're not specifying UTF8 anywhere:
> $template->process('utf-example.tmpl', $vars)
> || die "Template process failed: ", $template->error(), "\n";
>From the docs:
Alternately, the binmode argument can specify a particular IO layer such
as ":utf8".
$tt->process($infile, $vars, $outfile, binmode => ':utf8')
|| die $tt->error(), "\n";
or you can add a UTF8 BOM to the beginning of each template:
I use the script below to automatically update the UTF8 BOM on my
templates:
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
our $root = '/path/to/templates';
our $bom = "\x{EF}\x{BB}\x{BF}";
$| = 1;
process_dir($root);
sub process_dir {
my $dir = shift;
my @files = glob( $dir . "/*" );
foreach my $file (@files) {
if ( -f $file && $file =~ /\.tt$/ ) {
process_file($file);
}
elsif ( -d $file && $file !~ m|/\.svn| ) {
process_dir($file);
}
}
}
sub process_file {
my $name = my $file = shift;
$name =~ s/^$root//;
print sprintf( "Processing : %-50s", $name );
local ( *FH, $/ );
open( FH, '<:bytes', $file )
or die "can't open $file: $!";
my $a = <FH>;
close FH;
my $b = $a;
$a =~ s/$bom//g;
$a = $bom . $a;
if ( $a ne $b ) {
open( FH, '>:bytes', $file )
or die "can't write to $file : $!";
print FH $a;
close FH
or die "can't close file $file";
print " ...Updated\n";
}
else {
print "\n";
}
}
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates