tags:

views:

527

answers:

2

My delicious-to-wp perl script works but gives for all "weird" characters even weirder output. So I tried

$description = decode_utf8( $description );

but that doesnt make a difference. I would like e.g. “go live” to become “go live” and not “go live” How can I handle unicode in Perl so that this works?

UPDATE: I found the problem was to set utf of DBI I had to set in Perl:

my $sql = qq{SET NAMES 'utf8';};
$dbh->do($sql);

That was the part that I had to set, tricky. Thanks!

+1  A: 

It may have nothing to do with Perl. Check to make sure you're using UTF encodings in the pertinent MySQL table columns.

BipedalShark
The tables were in UTF but I had to add the set names to the DBI in perl...
edelwater
+1  A: 

It's worth noting that if you're running a version of DBD::mysql new enough (3.0008 on), you can do the following: $dbh->{'mysql_enable_utf8'} = 1; and then everything's decode()ed/encode()ed for you on the way out from/in to DBI.

Penfold