[Catalyst] TT and UNICODE: Garbled special characters

Tobias Kremer list at funkreich.de
Wed Sep 5 08:16:24 GMT 2007


Quoting Stefan Kühn <ducdebreme at early-dance.de>:
> I have a problem when outputting special characters with
> Template-Toolkit and C::P::Unicode. I passed a simple template
> parameter from the controller to the view. The parameter contains a
> special character and is being garbled in the output.
> * In controller test.pm > added the following (note the German Umlaut)
> sub index : Private {
>     my ( $self, $c ) = @_;
>         $c->stash->{myname} = 'düc'; # <-- **NOTE** the German Umlaut
>         $c->stash->{template} = 'test.tt2';
> }

If you use special characters as string literals you have to "use utf8" at the
top of your controller.

Other than that you should tell TT that your templates are UTF-8 encoded by
passing it a configuration option in your View class:

__PACKAGE__->config( {
    ...
    ENCODING            => 'utf-8',
    ...
} );

HTH,

--Tobias



More information about the Catalyst mailing list