Hi.

When I use a value from DBD::SQLite added with 
Japanese character, they will be changed to insert \xC2 into 
each bytes (ex. \xa4xa2 +  \x31 -> \xc2\xa4\xc2\xa2\x31).
But with ASCII characters, DBD::mysql or unpacked-packed, 
there is no problem. I can't find out why.
Would anyone tell me why?

[Environment]
perl        :  v5.6.1 built for sun4-solaris 
DBI         : 1.13
DBD::SQLite : 0.12
DBD::mysql  :2.0410

[Source]
#!/bin/perl
use strict;
use DBI;
sub testFunc($);
my $hDb1 = DBI->connect('dbi:SQLite:test', '', '',
            {AutoCommit=>0, RaiseError=>1});
my $hDb2 = DBI->connect('dbi:mysql:dbname=hippo2000', 'hoge', 'hoge',
       {AutoCommit=>1, RaiseError=>1});
print "$DBD::SQLite::VERSION\n";
print "\nCASE 1:\n";
testFunc($hDb1);
print "\nCASE 2:\n";
testFunc($hDb2);
$hDb1->disconnect;
$hDb2->disconnect;

sub testFunc($) {
    my($hDb) = @_;
    my $raD;
    my ($sWk1, $sWk2, $sWk3, $sWk4, $sPre, $sNew);
    my $sJpn = "\xA4\xA2"; #Japanse character A (HIRAGANA)
    my $sAsc = 'AB';
    eval {$hDb->do('DROP TABLE TEST');};
    $hDb->do('CREATE TABLE TEST (TESTID INTEGER)');
    $hDb->do('INSERT INTO TEST VALUES(1)');
    my $hSt =  $hDb->prepare('SELECT TESTID FROM TEST');
    $hSt->execute;
    $raD = $hSt->fetchrow_arrayref();
    $sPre = $raD->[0]; 
    $sNew = pack('H*', unpack('H*', $raD->[0]));
    $sWk1 = $sJpn . $sPre;
    $sWk2 = $sJpn . $sNew;
    $sWk3 = $sAsc . $sPre;
    $sWk4 = $sAsc . $sNew;
    print "SAME? : ", ($sPre eq $sNew)? 'SAME': 'DIFF', "\n";
    print unpack('H*', $sWk1) , "\n";
    print unpack('H*', $sWk2) , "\n";
    print unpack('H*', $sWk3) , "\n";
    print unpack('H*', $sWk4) , "\n";
    $hSt->finish;
}

[result]
0.12

CASE 1:
SAME? : SAME
c2a4c2a231
a4a231
414231
414231

CASE 2:
SAME? : SAME
a4a231
a4a231
414231
414231

==============================================
Kawai, Takanori(Hippo2000)
   Mail: [EMAIL PROTECTED] [EMAIL PROTECTED]
   http://member.nifty.ne.jp/hippo2000
==============================================

Reply via email to