in reply to Re: Re: Perl Mysql and UTF8
in thread Perl Mysql and UTF8

Oh! Well, that means that it is $dbh->quote(...) that is hosing your data. I would really recommend that you look into using binds for your dynamic literals rather than quoting them.

If you are not familiar with binds (or "placeholders", depending on the documentation source), then you should really look into them. The basic idea is that, instead of doing this:

my $quotedvar = $dbh->quote($var); my $sql = "insert into mytable (mycolumn) values ($quotedvar)"; $dbh->do($sql);
do this:
my $sql = "insert into mytable (mycolumn) values (?)"; $dbh->do($sql,undef,$var);
But you should definiftely consult the DBI docs for more info on this (see the section under "Placeholder and Bind Values").

I'm really not at all surprised that $dbh->quote(...) is mangling your data, because, well, that's what its job is, and apparently it is just getting a little bit over-zealous with its mangling. More to the point, it may not be character-encoding-aware... wheras simply binding the value just passes it directly through to the DBD. And, in the case of mysql, the DBD is probably capable of handling character-encoding well, since there is explicit functinoality around it in the database.


------------
:Wq
Not an editor command: Wq