[Catalyst] Catalyst crashing hard with UTF-8 string

Tomas Doran bobtfish at bobtfish.net
Wed Jul 15 21:23:08 GMT 2009


On 13 Jul 2009, at 15:33, Paul Makepeace wrote:

> Summary: this turns out to be an issue with Catalyst::Engine::HTTP's
> Remote handle not being set to UTF-8.


Setting the remote handle to utf8 makes perl automagically encode  
everything from a utf8 character string into a byte string (for you).

This isn't the engine's job.

It's the rendering pipeline's job to ensure that you have a document  
whos body is a string of bytes (rather than perl's internal characters).

Catalyst::Plugin::Unicode does this for you by calling uft8::encode  
(the perl internal character string is encoded into a byte string (in  
utf8)).

>
> my $error = "It\x{2019}s crazy";
> my $template = \'[% foo %]';  # or 'path/to/template';
>
> my $output = $view->render($c, $template, {foo => $error});
> binmode(*STDOUT, ':utf8');
> print "Output: $output\n";
> __END__
>
> It turns out that it's not the rendering in TT at all(!) as evidenced
> by this test script working.
>
> **
>
> So I can now produce this hard crash by replacing
> MyApp::View::TT::render with sub render { "\x{2639}" }. Digging even
> further back I found this has it work,
>

I can't see a crash at all here, that's shitty :/.

Cheers
t0m




More information about the Catalyst mailing list