Perl Monk, Perl Meditation | |
PerlMonks |
Re: A UTF8 round trip with MySQLby Joost (Canon) |
on Jun 13, 2007 at 02:22 UTC ( [id://620863]=note: print w/replies, xml ) | Need Help?? |
DBD::mysql 4.004 ( and higher with mysql_enable_utf8 will (or, should) correctly detect any retrieved utf-8 columns (i.e. it will set the utf8 flag on them). That means that retrieved strings will just do the right thing.
update: really, don't use any lower version for this - 4.003 and 4.004 contain some important utf8 fixes In other words, you should probably not use encode_utf8() on query results. Especially since that discards the utf8 flag. INSERTing data into utf-8 columns is trickier. As far as I know you still need to make sure the data is really utf-8 encoded. You can use utf8::upgrade() for that. Do not use methods (like encode_utf8()) that convert to utf-8 but don't set the utf-8 flag for this purpose, since if/when this issue in DBD::mysql gets fixed, those methods will not work correctly.
In Section
Meditations
|
|