Perl-Sensitive Sunglasses | |
PerlMonks |
UTF8 to Mysql transformed by mysql.so?by jabowery (Beadle) |
on Jun 21, 2012 at 15:13 UTC ( [id://977667]=perlquestion: print w/replies, xml ) | Need Help?? |
jabowery has asked for the wisdom of the Perl Monks concerning the following question:
DBD::mysql is transforming valid utf8 into gibberish(?) on the way through mysql.so:
UPDATE mysql.so is doing a gratuitous utf8::encode($s) on strings that have the utf8::is_utf8($s) bit set. I was able to compensate for this by performing this just prior to the call to mysql's execute: for(keys %$row){utf8::decode($row->{$_}) if utf8::is_utf8($row->{$_})}END UPDATE Neither use open ':utf8' nor use open ':encoding(UTF-8)'; changed the bogus behavior.A table, the dump for which starts:
is being inserted (field 'content') with a valid UTF8 string (as verified with Test::utf8's "is_sane_utf8" and "is_flagged_utf8") as the bind input to the "execute" method. The connection was opened with:
And strace verifies the "SET NAMES utf8" command is traversing the socket from the client to the server. Moreover the query: show VARIABLES LIKE 'character_set%';results in:
However, strace of the data going from the client to the server shows an octet string that has everything intact (ie: 'INSERT INTO.... regular ascii data for content, etc') except the multi-octet utf8 characters. They've been transformed. An example is: Is it time to go to uuencode or carrier pigeon with the elder futhark or something?
Back to
Seekers of Perl Wisdom
|
|