Re: DBD::mysql and utf-8 problem

Helmut Zeilinger <[email protected]> Fri, 27 Jun 2008 13:58:10 +0200
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
Hi Dwalu,

that is clear... I checked that (in the same script) by

..
my $vars = $dbh->selectall_arrayref (qq (show variables like 'char%'));

foreach my $var (@$vars) {
    print qq ($var->[0] = $var->[1] \n);
}
..

which prints out

"character_set_client = utf8
character_set_connection = utf8
character_set_database = utf8
character_set_filesystem = binary
character_set_results = utf8
character_set_server = utf8
character_set_system = utf8
character_sets_dir = /usr/share/mysql/charsets/"


So i think, this is not the problem.

Just an idea:

In the source code of the DBD::mysql driver i found the
function "sv_utf8_decode"  processing the utf8 results.

Wouldn't "sv_utf8_downgrade" make sence?


Thanks

Helmut



Dwalu Z. Khasu schrieb:
> On Fri, 27 Jun 2008, Helmut wrote:
>
> =>Hi all,
> =>
> =>after looking for utf8 issues in this mailing list, i had the feeling,
> =>there would be no problems concerning utf8 and the
> =>DBD::mysql driver anymore.
> =>
> =>However i still have a problem. The (simplified) script:
> =>
> =>[..]
> =>my $aeu = "\N{LATIN SMALL LETTER A WITH DIAERESIS}";
> =>
> =>my $dbh = DBI->connect ("DBI:mysql:test:localhost;mysql_enable_utf8=1", 
> =>"test");
> =>my $text = $dbh->selectrow_array (qq (select ?), undef, $aeu);
> =>
> =>print qq (length $text = ), length $text, "\n";
> =>$text = decode ("UTF-8", $text);
> =>print qq (length decoded $text = ), length $text,"\n";
> =>[..]
> =>
> =>results in =>
> =>
> =>length Ã? = 2
> =>length decoded ä = 1
> =>
> =>on an iso-8859-1 console.
> =>
> =>
> =>Questions:
> =>Why does Perl not calculate the correct number of characters?
> =>Does one (still) have to decode every string value received from the 
> =>DBD::mysql driver?
> =>
> =>
> =>Thanks for any Help
> =>
> =>Hemut
> =>
> =>
> Hello Hemut,
>
> It's not a problem with the driver or perl.  You need to configure the 
> server or connection to return your specific charset, else it defaults to 
> latin1 IIRC.
>
> See: http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
>   


-- 
HZ.labs
Dr. Helmut Zeilinger
Wiesengrund 2
D-86 684 Holzheim
Tel.     08276 58767
Fax.     08276 58787
Mobil    0160 91 55 61 68
Internet http://www.hzlabs.de
Mail     [email protected]


-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]