Hi.

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 28, 2004 4:32 PM
Subject: MultiByte Character Sets and False Matches


> Is there any support in the DBD package (or any workarounds) for
> handling searches in MultiByte Character Set data?
How about this sample?
This script works on my Linux box (ie Only NO=2 are selected). 
But not works correctly on my Windows one. It gets 2 lines.
Just because, MySQL on my Windows uses ShiftJIS not EUC-JP.

Of course, if you want to use DBD::CSV, you should consider to use
UTF8.

----------------------------------------------
[sample]
use strict;
use DBI;
my $hDb = DBI->connect('dbi:mysql:hoge', 'usr', 'pwd', 
        {PrintError=> 0, AutoCommit=>1, RaiseError=>1}) 
    or die 'CONNECT ERROR';

eval{$hDb->do('DROP TABLE t1');};
$hDb->do('CREATE TABLE t1 (NO integer, NAME varchar(40))');
$hDb->do('INSERT INTO t1 VALUES(?, ?)', undef, 
     1, "\xA5\xC6\xA5\xB9\xA5\xC8"); # TESUTO in KATAKANA (EUC-JP)
$hDb->do('INSERT INTO t1 VALUES(?, ?)', undef, 
     2, "\xB9\xA5\xA4\xAD");         # SUKI in KANJI+HIRAGANA(EUC-JP)
my $hSt = $hDb->prepare("SELECT * FROM t1 WHERE NAME like ?");
$hSt->execute("%\xB9\xA5%");  #SUKI in KANJI(EUC-JP)
while(my $raD = $hSt->fetchrow_arrayref()) {
  print join(',', @$raD), "\n";
}
$hDb->disconnect();

----
[Result]
1) On Linux:
[EMAIL PROTECTED] kawait]$ perl t1.pl
2,好き

2) On Windows
C:\temp>perl t1.pl
1,・ニ・ケ・ネ
2,ケ・、ュ

==============================================
KAWAI, Takanori(Hippo2000)
   Mail: [EMAIL PROTECTED] [EMAIL PROTECTED]
   http://member.nifty.ne.jp/hippo2000/index_e.htm
   http://www.hippo2000.info/cgi-bin/KbWikiE/KbWiki.pl
 May we translate your pods into Japanese?
    -- Japanized Perl Resource Project
  http://sourceforge.jp/projects/perldocjp/
==============================================

Reply via email to