[Catalyst] TT and UNICODE: Garbled special characters

Stefan Kühn ducdebreme at early-dance.de
Wed Sep 5 07:45:29 GMT 2007


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.

I studied the mailing list the whole afternoon, but could not find the solution.

This is, what I did

* Created the project
 catalyst.pl CatUtf

* Created the view
 script\catutf_create.pl view TT TTSite

* added Added C::P::Unicode to CatUtf.pm

* created the controller
 script\catutf_create.pl controller test

* 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';
}

* Created root/src/test.tt2
<h1>hallo</h1>
<p>[% myname %]</p>

* Started the server
D:\dev\eclipse\CatUtf>script\catutf_server.pl –r

* Accessing the server http://localhost:3000/test : found garbled
special character (German Umlaut)
__
hallo
d?
__

I even tried to add the ENCODING paramter in CatUtf::V::TT.pm like so:

__PACKAGE__->config({
    CATALYST_VAR => 'Catalyst',
    INCLUDE_PATH => [
        CatUtf->path_to( 'root', 'src' ),
        CatUtf->path_to( 'root', 'lib' )
    ],
    PRE_PROCESS  => 'config/main',
    WRAPPER      => 'site/wrapper',
    ERROR        => 'error.tt2',
    TIMER        => 0,
    ENCODING => 'UTF-8'
});


Has anyone a clue?
Is there a way apart from ForceUtf8 (which is said to be "Hack Hack Hack")?


--

-----------------------------------------------------------------------------
Stefan Kuehn - Le Duc de Brême
The Calendar of Historical Dance  --  http://www.early-dance.de
-----------------------------------------------------------------------------


-- 

-----------------------------------------------------------------------------
Stefan Kuehn - Le Duc de Brême
The Calendar of Historical Dance  --  http://www.early-dance.de
-----------------------------------------------------------------------------



More information about the Catalyst mailing list