perl-unicode

Re: i know it's utf-8, how can i force perl to see it that way

2003-06-18 06:30:04
On Mon, Jun 16, 2003 at 10:10:52AM -0400, Nathaniel W. Turner wrote:
The crux of the problem is that mysql thinks it knows what it's doing, and is 
assuming incoming data is latin1*, and thus storing your bytes as though they 
were latin1.  
[...]
*or somesuch 1-byte encoding; 
that diagnosis is exatly right.  that's why all the
latin1 characters were ok, and the non latin1 characters
got mangled

mysql doesn't support utf-8, even in version 4, 
despite whatever claims they may make on their website.  I'm not bitter.  No, 
sir.
4.1.0.alpha does, i actually got it to work now!
(with an example that contains latin1 and latin2 characters,
so it *has* to be unicode)

all you need to do is to convert every utf8 string you
feed into mysql into ..... utf8!

  INSERT INTO table VALUES (.... CONVERT(_utf8'blabla' USING utf8)....)

that goes for all literal strings, not only in inserts but also
in selects:

  SELECT FROM table WHERE col LIKE CONVERT(_utf8'%blabla%' USING utf8)

I use this, from perl, through DBI, and I get back classical
perl strings that contain utf8.  so I need another

  $dbresult = decode("utf8", $dbresult);

and I'm done!

     thanks for all 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
bjelli(_at_)horus(_dot_)com                         
http://www.horus.com/~bjelli/
http://perlwelt.horus.at http://www.perlmonks.org/index.pl?node=bjelli