[Catalyst] Re: Catalyst, utf8 in form element type text - Solved

Marius Kjeldahl mariusauto-catalyst at kjeldahl.net
Mon May 5 20:22:19 BST 2008

Bill Moseley wrote:
>> use base 'Catalyst::View::TT::ForceUTF8';
> That seems like the wrong approach.
> Data should be decoded on input from the outside and encoded on
> output.  I'm not sure when it would be advisable to force utf8 flag
> on items in the stash, but I have not looked at that module in a
> while.
> <form> tags should have accept-charset

I tried this but couldn't get it working correctly, which may be 
entirely my fault of course.

> C::P::Unicode::Encoding should be used (I suggest with reservations).
> That will decode parameters and encoding output.

I looked into this and related modules trying to figure out exactly 
where to do what, which lead me to the solution posted.

> If your templates are UTF8 then ENCODING => 'UTF-8' when creating TT
> object.

Tried this as well. Didn't work. As far as I managed to figure out, that 
solution requires the plugin you mentioned, or a similar one (possibly 
ending in Encode instead of Encoding - I'm taking this from memory while 
googling for a solution to my problem).

> Do what's required for your database to handle utf-8.

In my case, everything is utf8. The source code (with embedded strings), 
the database and I see no reason to start juggling back and forth 
between encodings unless there is a specific need. There may be one, 
which I'm sure further testing will demonstrate, but for now I'm ok.

Actually, I found one place where it was actually needed already. I'm 
using some of the Yahoo YUI "ajax" components which didn't work great 
with utf8, and a simple "decode" (from utf8) before returning some 
values in a ajax component seemed to solve it just. There may be flags 
that can be set in the YUI library which enable utf8 encoding also, 
which would probably be a better solution.


Marius K.

More information about the Catalyst mailing list