On 2006-03-29 09:58:16 -0800, Mark Hedges wrote: > On Wed, 29 Mar 2006, Tim Bunce wrote: > > On Wed, Mar 29, 2006 at 10:53:56AM +0200, Peter J. Holzer wrote: > > > Since mysql supports different charsets per table and even per column, > > > I'd like an option to automatically convert them to and from perl's > > > internal UTF-8 encoding. > > > > > > (Actually, I'd like that to be the default behaviour, but it probably > > > would break a lot of existing scripts, so it should be an option at > > > first) > > > > I think that translates into just asking DBD::mysql to set the > > 'connection charset' to utf8 and then mysql server will look after the > > conversions for you. > > Hmmm, I tried setting the default connection charset: [...] > But the scalars selected from a utf8 field still do not have the > utf8 flag set in perl.
That has been my experience as well. DBD::mysql will just pass everything through unaltered. So if you use UTF-8 as connection charset, you have to encode('utf-8', ...) all queries and parameters, unless you are sure that they are either plain ASCII or already have the UTF-8 bit set. And you will get raw UTF-8 strings back, which you have to decode() explicitely. However, I notice that on Debian Sarge (on which I did my testing), libdbd-mysql-perl depends on libmysqlclient12. So there may be a problem with mixing releases (The server is 4.1, but libmysqlclient12 belongs to 4.0, which doesn't know about UTF-8). hp -- _ | Peter J. Holzer | If I wanted to be "academically correct", |_|_) | Sysadmin WSR | I'd be programming in Java. | | | [EMAIL PROTECTED] | I don't, and I'm not. __/ | http://www.hjp.at/ | -- Jesse Erlbaum on dbi-users
pgp7K0E14XpOu.pgp
Description: PGP signature