[Dbix-class] Unicode conversion problems

Matias E. Fernandez pisco at gmx.ch
Mon Jul 5 15:45:11 GMT 2010


Hello Jesse

Please try the following using the table 'foo' you described earlier:

mysql> set names utf8;
mysql> insert into foo (author) values('Pérez-Reverte, Arturo Кири́ллица ქართული  汉字 / 漢');

then try this script, notice the attributes which in this case are very important:

use strict;
use warnings;

use DBI;

my $attributes = {
	'mysql_enable_utf8'    => 1,
	'mysql_auto_reconnect' => 0
};
my $dsn = "DBI:mysql:database=foo";
my $username = "test";
my $password = "";

my $dbh = DBI->connect($dsn, $username, $password, $attributes) or die($DBI::errstr);

my $sth = $dbh->prepare("SELECT * FROM foo");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
	print "$ref->{'author'}\n";
}
$sth->finish();

What do you get there?

Regards
Matias E. Fernandez




More information about the DBIx-Class mailing list