At 8:42 -0400 6/18/03, Hardy Merrill wrote:
I've been following this thread with interest - really
curiosity.  Your workaround seems like a lot of work -
have you tried posting your question on a mysql mailing
list?

Paul Dubois has written some very good books on MySQL
with sections on DBI use - I think Paul is on this list -
I'm hoping Paul will respond with what he knows about
utf8 use in MySQL.

My suggestion is that if you're using 4.1.0, wait for 4.1.1 and try it again. There are lots of character-set-handling related changes, and the problem you're seeing may well be fixed. I know that some of the new work involves transmission of information between client and server.

If you *are* using 4.1.1 from the development tree (and thus the
problem remains unsolved), then please report your findings to
bugs.mysql.com so that the problem can be addressed.  Thanks!


-- Hardy Merrill Red Hat, Inc.

Brigitte Jellinek [EMAIL PROTECTED] wrote:

Yesterday I wrote about problems with reading utf8, later I realized that the problems were actually in the inserting, not the reading. Today I found a workaround.

 The problem is caused by mysql, not by perl.
 Maybe I'm doing something really stupit, but it seems
 that my mysql-server doesn't accept utf8 as utf8. In the
 most basic version, using a utf-8 file with sql commands:

mysql --default-character-set=utf8 test < test-insert.sql

 my mysql server still interprets the utf8 strings in the file
 as latin1 (and mangles all the non-latin1-charachters).

I tried inserting

SET CHARACTER SET utf8;

into the file, but that didn't help.

 I had to change all occurences of literal utf8 strings in my SQL
 statements, like so:

INSERT INTO sometable VALUES (....,CONVERT(_utf8'blabla' USING utf8), ...);

 where 'blabla' is a string that might contain utf8.�
 the same for SELECT:

    SELECT * FROM sometabel
    WHERE somecolumn LIKE CONVERT(_utf8'%blabla%' USING utf8);

 I now use this workaround through DBI. the data I get back is
 not flagged as utf8, but it is correct utf8, so I can decode it
 without a problem:

     # to search for books with a title containging $char:
     my $sql = qq{
                 SELECT * FROM buch WHERE Originaltitel LIKE
                  CONVERT(_utf8 '%$char%' USING utf8)����������
                 };
     my $sth = $dbh->prepare($sql);
     $sth->execute();

     my (@r, $i);
     while( @r = $sth->fetchrow_array() ) {
         $_ = decode("utf8", $_) foreach @r;
         print "<p>@r</p>";
     }

It works. I'm glad. Thanks for the help.

Brigitte


p.s. you can find the details at http://perlwelt.horus.at/Beispiele/Magic/PerlUnicodeMysql/

 --
 Brigitte        'I never met a chocolate I didnt like'        Jellinek
 [EMAIL PROTECTED]                         http://www.horus.com/~bjelli/
 http://perlwelt.horus.at http://www.perlmonks.org/index.pl?node=bjelli



Reply via email to