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.

Thanks.

Tim.

On Tue, Jun 17, 2003 at 11:57:25AM +0200, Brigitte Jellinek wrote:
> 
> hi!
> 
> I'm not sure this is supposed to work yet.... 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:
> 
> he string i write into the db is 6 characters long:
> "A\N{greek:beta}cd\N{cyrillic:e}f"
> 
>     character           unicode utf8
>                         hex     binary
> 
>     A                   0041    01000001
>     ?                   03B2    1100111010110010
>     c                   0063    01100011
>     d                   0064    01100100
>     ?                   044D    1101000110001101
>     f                   0066    01100110 
> 
> what i get back from the db is
> 
>     A                           01000001
>     ?                           11001110
>     ?                           10110010
>     c                           01100011
>     d                           01100100
>     ?                           11010001
>     ?                           00111111
>     f                           01100110
> 
> 
> look at the penultimate byte!  Is that supposed to happen?
> 
> 
> 
> 
> PS. 
>     I compiled everything myself, and used the following versions:
>     perl(5.8) + dbi(1.37) + dbd::mysql(2.1026) + mysql(4.1.0-alpha) 
> 
> Here's the code I use:
> 
>     $dbh = DBI->connect("DBI:mysql:test", "someuser", "somepass");
> 
>     $uni = "A\N{greek:beta}cd\N{cyrillic:e}f";
> 
>     $dbh->do("INSERT INTO unitest VALUES (NULL,?,?)", undef, $uni, $uni)
>       or print $dbh->errstr;
> 
>     $id = $dbh->{insertid};
> 
>     $sth = $dbh->prepare("SELECT * FROM unitest WHERE ID = ?");
>     $sth->execute( $id );
>     @row = $sth->fetchrow_array();
> 
> 
> The table is a utf-8 table:
> 
>     CREATE TABLE unitest (
>       ID mediumint(9) NOT NULL auto_increment,
>       vc varchar(80) default NULL,
>       t text,
>       PRIMARY KEY  (ID)
>     ) TYPE=MyISAM CHARSET=utf8;
> 
> 
> 
> PPS.: I keep a journal about my adventures with perl+mysql+unicode
> at http://perlwelt.horus.at/Beispiele/Magic/PerlUnicodeMysql/
> 
> -- 
> 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

Reply via email to