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/

In reply to MySQL, DBIx::Class and UTF-8 by holli

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.