encoding - Perl unicode handling with DBI -
i using spreadsheet::read data excel (xls or xlsx) files , put them in mysql database using dbi.
if print out data console, displays special characters properly, when insert database, files end corrupted characters. example, "möbelwerkstätte"
becomes "möbelwerkstätte"
.
i think spreadsheet::read
"knows" character set coming out of file, prints console each time, regardless of file encoding. how make sure going database in utf-8?
both dbi , dbd::mysql defaults latin1 (compiled latin1).
sending "use names utf8" first query change session.
from manual:
set names indicates character set client use send sql statements server. thus, set names 'cp1251' tells server, “future incoming messages client in character set cp1251.” specifies character set server should use sending results client. (for example, indicates character set use column values if use select statement.)
see http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html full documentation.
Comments
Post a Comment