[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Character Encoding (UTF-8) in PERL



Oliver König dijo [Sun, May 13, 2007 at 05:52:54PM +0200]:
> > I think that, as Etch is by default installed with UTF on everywhere,
> > we should propose changing this default, so that MySQL connections are
> > also UTF by default. This could enter Etch 4.0r1 (or further). What do
> > you think?
> >
> My mysql settings are fine. The problem is PERL. 
> 
> mysql> SHOW VARIABLES LIKE "character_set_%";
> +--------------------------+----------------------------+
> | Variable_name            | Value                      |
> +--------------------------+----------------------------+
> | 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/ |
> +--------------------------+----------------------------+
> 
> However the command dbh->do(SHOW VARIABLES LIKE "character_set_%");  excuted 
> in a PERL script returns:
> character_set_client      latin1
> character_set_connection  latin1
> character_set_database    utf8
> character_set_filesystem  binary
> character_set_results     latin1
> character_set_server      utf8
> character_set_system      utf8
> character_sets_dir        /usr/share/mysql/charsets/
> 
> Everybody is blaming mysql but it is obvious to me that PERL is the problem. 
> How do I configure PERL tu use UTF-8 as default???

Exactly - The problem is not Perl the language, but the connection
settings expressed by the glue between Perl and MySQL, the DBD::mysql
module - Just as you configure your MySQL defaults in
/etc/mysql/my.cnf and ~/.my.cnf (and use some default values),
DBD::mysql is configured partially (I guess) at build time, and part
can be specified at invocation time. For example, under the 'connect'
statement from the DBD::mysql manpage, I found:

    $dsn = "DBI:mysql:test;mysql_read_default_file=/home/joe/my.cnf";

Later on, in the 'DATABASE HANDLES' section, I found:

    mysql_enable_utf8
        This attribute determines whether DBD::mysql should assume
        strings stored in the database are utf8.  This feature
        defaults to off.

And what I'm suggesting is to change this default, if there is no
reason not to do so.

Now, seeing this is the documented behaviour, I do not think anymore
this should be changed for Etch (users might be relying on the
opposite behaviour), but for Lenny.

Greetings,

-- 
Gunnar Wolf - gwolf@gwolf.org - (+52-55)5623-0154 / 1451-2244
PGP key 1024D/8BB527AF 2001-10-23
Fingerprint: 0C79 D2D1 2C4E 9CE4 5973  F800 D80E F35A 8BB5 27AF



Reply to: