Character encodings and databases
Jason Clifford
jason at ukfsn.org
Fri Jun 20 16:54:09 BST 2014
On 2014-06-20 09:37, Andrew Hill wrote:
> my $zurich = "Zürich";
> $dbh->do("delete from foo");
> my $sth = $dbh->prepare("INSERT INTO foo (bar) values (?)");
> $sth->execute($zurich);
> $dbh->commit;
> $sth = $dbh->prepare("select bar from foo");
> $sth->execute;
> my$foo = ($sth->fetchrow_array)[0];
> $sth->finish;
> $dbh->disconnect;
> print HexDump $foo;
> print HexDump $zurich;
>
> This outputs:
> 00000000 5A FC 72 69 63 68 Z.rich
> 00000000 5A C3 BC 72 69 63 68 Z..rich
Did you 'use utf8;' in your script?
$zurich contains bytes but should contain characters and that usually
means you didn't.
More information about the london.pm
mailing list