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
  • 124,803
  • 31
  • 200
  • 568
Pedro
  • 1,370
  • 2
  • 12
  • 30

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
  • 31,930
  • 6
  • 24
  • 40