On Wed, Jan 8, 2014 at 9:22 AM, Dave Howorth <dhowo...@mrc-lmb.cam.ac.uk>wrote:
> I have some templates that generate web pages. The templates themselves > only contain ASCII*. ASCII is a subset of UTF-8, so I'd use: ENCODING => 'UTF-8'. Then Template::Provider will decode the templates when loading. > They include some data that is extracted from a > database and some of the data values are now Unicode UTF-8 (they contain > non-break space and some quote marks). But the resultant HTML file that > is generated contains the Windows-1252 code for these characters (i.e. > single byte values rather than double). > Then, as you mentioned in your DBIx::Class post, you need to tell the DBD driver that your database is in UTF-8. Then the DBD driver will decode when reading. Then you have "characters" inside of Perl. > What is the best way to persuade TT to generate a Unicode file? > I would do something like this: $tt->process( $template, \%vars, \$output ); $bytes = Encode::encode_utf8( $output ); Or have $output be a filehandle with a utf-8 output layer. > > * Actually, there is one sub-template that is PROCESSED that contains a > Unicode copyright symbol and that is put in the output file unchanged. > Just to confuse me further. > Just make sure you use the utf-8 character for that in your template.
_______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates