Did you use both ENCODING => 'utf8' in "new" and binmode =>
':encoding(utf8)' in "process"?

There is more about it at this web page:

http://www.lemoda.net/perl/template-encoding/index.html




On 21 October 2014 16:44, David Hickman <david.hick...@it.ox.ac.uk> wrote:

>  Dear all,
>
>
>
> I wondered if anyone had any experience of using the Perl Template Toolkit
> and UTF-8 encoded files? I appear to be facing a rather Strange issue with
> a UTF-8 encoded template file (although the only UTF-8 encoded characters
> in the file are the £ sign):
>
>
>
> • If I don’t tell the template toolkit anything about the encoding of the
> template file then the resulting output from the template is correct and
> the £ signs are output in UTF-8 format
>
>
>
> • If I specifically tell the template toolkit that the file is encoded in
> UTF-8 (either using the configuration parameters, a BOM on the template
> file, or both) then the £ signs in the template are converted to character
> code 163 (the ANSI equivalent). This breaks my intended output of the
> template as the character encoding reported to the browser in the response
> header is UTF-8 even though the file now contains characters that are  not
> compatible with UTF-8.
>
>
>
> • If I add some “definitely Unicode” characters (自河南经乱关) to the template
> and don’t change anything else in the file at all, then the output from the
> file works fine regardless of whether I tell the template toolkit that the
> file is UTF-8 or not.
>
>
>
>
>
> Does anyone have any ideas about what might be going on and how I could
> fix this issue?  From what I have found from my investigation it appears as
> though the £ sign sits in a character range that can cause Perl to change
> its interpretation of a string and I wonder if this might be causing a
> problem somewhere down the line?  It might be worth mentioning that the
> template toolkit is configured to compile templates in memory rather than
> writing to disk.
>
>
>
>
>
> Any pointers would be most gratefully received as I am rather stuck!
>
>
>
>
>
> Best Regards,
>
> David
>
>
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
>
_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to