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 [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
