[Catalyst] UTF-8 strings getting stragely converted to latin1 when coming from MySQL DB

Matt S Trout dbix-class at trout.me.uk
Thu Mar 2 17:07:54 CET 2006


On Thu, Mar 02, 2006 at 04:49:13PM +0100, Daniel McBrearty wrote:
> may not be related to your problem, but make sure you are issuing the "set
> names utf8" command to mysql at teh start of the session. This has bit my
> ass and caused me much headaches in the past ...
> 
> 
> http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
> 
> if you don't do this, mysql may take it upon itself to convert streams to
> some non utf8 form, even though you think you have told it really thoroughly
> that it shouldn't.

In your DBIC schema you can add

__PACKAGE__->storage->on_connect_do([ "set names utf8" ]);

to ensure this gets run immediately after the $dbh is (re-)connected.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list