4

I have a database with a list of articles in Chinese and I'm having a problem when I try to do my query to get all the articles names, all I see is ??? and not the Chinese text.

my $db_connection = DBI->connect("DBI:mysql:host=localhost;database=articles", 'root', ''); 
my $con  = $db_connection->prepare( "select * from articles" );

$con->execute;

while (my $infoD = $con->fetchrow_hashref())
{
    $INFO{$infoD->{name}} .=   decode('utf8', $infoD->{name});  
}
brian d foy
  • 129,424
  • 31
  • 207
  • 592
Pedro
  • 1,440
  • 2
  • 15
  • 36

1 Answers1

6

declare in your connection string also that it should use utf8

DBI->connect("DBI:mysql:host=localhost;database=articles", 'root', '',{mysql_enable_utf8 => 1}); 

If you have utf8mb4

you have to replace {mysql_enable_utf8 => 1} with {mysql_enable_utf8mb4 => 1}

Edit:

also see here UTF8 all the way

nbk
  • 45,398
  • 8
  • 30
  • 47