holli has asked for the wisdom of the Perl Monks concerning the following question:

Brethren, I have a little encoding problem. I have a MySQL table defined as follows
CREATE TABLE i18n ( Id varchar(50), Language char(2), Text text, PRIMARY KEY (Id,Language) ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci; ;
and a schema class for it
package Superclix::Schema::I18N; use strict; use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components(qw(Core UTF8Columns)); __PACKAGE__->table("i18n"); __PACKAGE__->add_columns( "Id" => { data_type => 'VARCHAR', is_nullable => 0, size => +50, accessor => 'name' }, "Language" => { data_type => 'VARCHAR', is_nullable => 0, size => +2, accessor => 'lang' }, "Text" => { data_type => 'TEXT', is_nullable => 0, accessor + => 'text' }, ); __PACKAGE__->utf8_columns(qw/Text/); 1;
But when I use the schema and read the russian characters stored in the table the results are only question marks. I tried decoding the field using Encode but that didn't help (same result). Can anybody shed some light on this?

TIA

Update:
Solved. The trick is to set mysql_enable_utf8 in the call to connect.


holli, /regexed monk/

Replies are listed 'Best First'.
Re: MySQL, DBIx::Class and UTF-8
by jeffa (Bishop) on Jan 14, 2009 at 14:18 UTC

    Try issuing this SQL command at your start up:

    set character set utf8
    That might just do the trick ...

    Update: Yes. I am very sure that what I posted works for me. Perhaps yours does the same thing. SQL has lots of aliases.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      Are you sure about double set?

      May be you mean:

      SET NAMES UTF8