Ian Docherty wrote:
Hi

I have a mysql database table and columns in the table with utf8_general_ci collation.

I can enter and read Bulgarian text (utf8) using phpmyadmin but cannot output it through DBIx::Class.

Am I using utf8_columns correctly?

Here is the output the code produces.

1: message = [Main Page] value=[???????? ????????]
2) message = [Main Page] value=[???????? ????????]

Here is the simplest code I can produce to demonstrate the problem.
Are there any other things I can do to investigate the problem?

Regards
Ian
########################

#!/usr/bin/perl -w
use strict;
use utf8;
use Encode;

########################
package DB::Main::Lexicon;

use base qw/DBIx::Class/;

__PACKAGE__->load_components(qw(PK::Auto UTF8Columns Core));
__PACKAGE__->table('lexicon');
__PACKAGE__->add_columns(qw(id language path message value notes));
__PACKAGE__->set_primary_key('id');
__PACKAGE__->utf8_columns(qw/value notes/);

########################
package DB::Main;

use base qw/DBIx::Class::Schema/;

__PACKAGE__->load_classes(qw(Lexicon));

########################
package main;

my $schema = DB::Main->connect('DBI:mysql:host=localhost;database=test_db','user','secret');

my $lex = $schema->resultset('Lexicon')->first;

# just output without encoding
print "1: message = [".$lex->message."] value=[".$lex->value."]\n";

# output encoded, based on advent calendar article http://catalyst.perl.org/calendar/2006/21 print Encode::encode('utf-8', "2) message = [".$lex->message."] value=[".$lex->value."]\n");

1;
Problem solved (I think). It was a combination of wrongly encoded data put into the database
and a mis-configuration of my Catalyst application.


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to