[Catalyst] Charset best practice

Bill Moseley moseley at hank.org
Fri Nov 2 15:33:35 GMT 2007


On Thu, Nov 01, 2007 at 04:07:30PM +0100, Dami Laurent (PJ) wrote:
> We also run a Catalyst app in french and iso-8859-1. 
> 
> Catalyst::View::TT is hardcoded in UTF8. So the trick is to define a
> subclass in which you override the process() method, and there you
> set $c->response->content_type('text/html; charset=iso-8859-1');


The OP said the templates were UTF-8.

If the templates are UTF-8 then you (should) have

    TT::View's ENCODING => 'UTF-8';

That will decode the UTF-8 templates into Perl's internal encoding.

Setting the content type won't automatically encode the content,
though.  That's why the Encoding::Unicode plugin does this in
finalize:

    $c->response->body( $c->encoding->encode( $c->response->body, $CHECK ) );

That plugin also will decode all incoming parameters.


-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list