Subject: | Catalyst::Plugin::Unicode::Encoding + HTML::String::TT skips encoding |
Hello,
I had another issue with HTML::String::TT where it was causing my utf-8 characters to not be encoded before output. E.g. "ΓΈ" would be output as \xf8 instead of \xc3\xb8. I am using the encoding => 'UTF-8' option in my Catalyst config. The problem seems to be that on line 71 of Catalyst::Plugin::Unicode::Encoding is the following code:
# Encode expects plain scalars (IV, NV or PV) and segfaults on ref's
$c->response->body( $c->encoding->encode( $body, $CHECK ) )
if ref(\$body) eq 'SCALAR';
When I use HTML::String::TT with Catalyst::View::TT, then $c->response->body isa HTML::String::Value and the encoding is never done. I got around this by adding this to my View::TT subclass:
around 'render' => sub {
my $orig = shift;
my $self = shift;
my $res = $self->$orig(@_);
return "$res";
};
Is this the correct way to solve this? If so, I'd be happy to contribute a doc patch. If not, what is the recommended way? Thank you and have a great day!
Cheers,
Fitz