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

Geoff Richards qef at ungwe.org
Thu Mar 2 17:35:22 CET 2006


On Thu, Mar 02, 2006 at 04:07:54PM +0000, Matt S Trout wrote:
> 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.

Note that DBD::mysql will not set the 'UTF8' flag on the strings, so
you have to be careful what you do with them or they'll get screwed up.

    http://rt.cpan.org/Public/Bug/Display.html?id=17829

-- 

--- Geoff Richards -------------><-------------- http://ungwe.org/ ---
"I tried to fling my shadow at the moon,
 The while my blood leapt with a wordless song."  --  Theodore Roethke



More information about the Catalyst mailing list