[Catalyst] Catalyst Unicode woes ...

Pedro Melo melo at simplicidade.org
Thu Aug 9 10:11:49 GMT 2007


On Aug 9, 2007, at 9:27 AM, Tobias Kremer wrote:

> Following up on a conversion I started on the DateTime mailing-list  
> I'd like to
> ask if it is really neccessary to use C::P::Unicode if a site uses
> utf8-encoding?
> I have the problem that up until now everything worked absolutely  
> fine without
> C::P::Unicode, Template::Stash::ForceUTF8,  
> Template::Provider::Encoding or any
> other unicode plugin because I believed that if everything is utf8  
> you don't
> really have to worry about it that much.
> Now I recently incorporated DateTime::Locale to get a list of  
> localized month
> names. Spitting them out in my templates revealed a <questionmark>  
> symbol
> instead of all german umlauts. I took a look at DateTime::Locale  
> and everything
> seems to be correct (use utf8 at the top, etc) so this can't be the  
> culprit.
> encode("utf8")-ing the month names makes them look correct. I asked  
> about this
> on the DateTime mailing list and everybody suggested a truckload of  
> plugins to
> incorporate in Catalyst which _ALL_ break everything else on my  
> site except the
> month names which are displayed fine then. It looks like everything  
> gets
> encoded twice when utilizing these plugins.
> So I must admit I'm stuck with this. What is the best-practice for  
> dealing with
> Catalyst and utf8? Do I really need C::P::Unicode to make this work  
> correctly?
> What about the various TT plugins? And why the heck is everything  
> double utf8
> encoded when using these plugins that everybody else seems to use?

I must admit that I'm in the "it works for me but don't ask me why"- 
camp at the moment.

A combination of:

   * DBIC and making sure output from text fields is UTF8  
(utf8_columns() is your friend, but depending on the DB, you might  
need more than that);
   * Catalyst::View::TT::ForceUTF8;
   * Catalyst::Plugin::Unicode

with those three, and making sure my TT templates are in UTF8 (no BOM  
was injured) I haven't had any problems, even with DateTime with a  
PT_pt locale.

Also if you use open(), make sure you use the three argument version,  
and stick '<:utf8' in the middle arg.

This works for *me*, but I haven't had the time to understand it  
totally. And I would love someone to tell me that there is a simpler  

Sincerely I would hope Cat to be utf8-by-default around version 6...

Best regards,
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo at simplicidade.org

More information about the Catalyst mailing list