> On Tue, Jun 17, 2003 at 11:57:25AM +0200, Brigitte Jellinek wrote:
> > [...] I write utf-8 into mysql -
> > that seems to work. but when I read it back, not only do I get
> > a "classical perl string" instead of an utf8 string, but also some
> > of the bits are broken:
On Tue, Jun 17, 2003 at 11:36:13AM +0100, Tim Bunce answered:
> Please try using another tool (eg mysqldump) to read the data from
> the db to check if the problem is related to inserting the data
> and/or retrieving it. Also try not using placeholders.
ok, i tried both: mysqldump confirms: the problem is not
in inserting, but in reading from the db.
To investigate this further, I wrote one-character strings into the db:
foreach (0x21 ... 0x7e, 0xa1 ... 0xff )
{
$char = pack "U", $_;
$dbh->do("INSERT INTO unitest VALUES (NULL,'$char','$char')")
or print $dbh->errstr;
$id = $dbh->{insertid};
$sth = $dbh->prepare("SELECT * FROM unitest WHERE ID = ?");
$sth->execute( $id );
@row = $sth->fetchrow_array();
# ....
}
I find that in the range 0xc0 to 0xdf the last three bits get set to
001:
write 11000011100 = \x{00C0}
read 11000011001
....
write 11000011100 = \x{00DF}
read 11000011001
The same holds for range 0x010d to 0x011f, range 0x0140 to 0x015f, range
0x1213 to 0x181f, range 0x1840 to 0x185f, and so on.
ps.
i use perl(5.8) + dbi(1.37) + dbd::mysql(2.1026) + mysql(4.1.0-alpha)
pps.
my table is
CREATE TABLE unitest (
ID mediumint(9) NOT NULL auto_increment,
vc varchar(80) default NULL,
t text,
PRIMARY KEY (ID)
) TYPE=MyISAM CHARSET=utf8;
--
Brigitte 'I never met a chocolate I didnt like' Jellinek
[EMAIL PROTECTED] http://www.horus.at/~bjelli
http://perlwelt.horus.at http://www.perlmonks.org/index.pl?node=bjelli