#!perl use strict; use warnings; use utf8; use DBI; use Devel::Peek; use Encode; my $dbh = DBI->connect('DBI:mysql:database:server;mysql_enable_utf8=1', 'username', 'password'); die DBI::errstr() unless $dbh; my $stmt = qq~SELECT raw FROM files WHERE file_id = ?~; my $sth = $dbh->prepare($stmt); $sth->execute(1); my $row = $sth->fetchrow_hashref(); my $raw = $row->{raw}; Dump $raw; $raw = decode('utf8', $raw); Dump $raw; $raw = encode('utf8', $raw); Dump $raw; exit(0); __END__ SV = PV(0x35b7900) at 0x328d0f0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x306df38 "\303\244\303\266\303\274\303\237kekse!\303\252"\0 CUR = 16 LEN = 24 SV = PVMG(0x3539908) at 0x328d0f0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0x306bbb8 "\303\244\303\266\303\274\303\237kekse!\303\252"\0 [UTF8 "\x{e4}\x{f6}\x{fc}\x{df}kekse!\x{ea}"] CUR = 16 LEN = 24 SV = PVMG(0x3539908) at 0x328d0f0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) IV = 0 NV = 0 PV = 0x306bb78 "\303\244\303\266\303\274\303\237kekse!\303\252"\0 CUR = 16 LEN = 24