Click here to get back home

Do Win32::ODBC module support Chinese characters when used with MS Access?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Do Win32::ODBC module support Chinese characters when used with MS Access? Rico Lopez Liparte 09-15-2004
Posted by Rico Lopez Liparte on September 15, 2004, 10:33 pm
Please log in for more thread options
Hello all,

I am a newbie to Perl & CGI (7 days).

I am using Perl 5.6 and using Win32::ODBC to connect to an MS Access
Database, where I do my Insert/Update/Delete.

I found that I can't correctly update a field's value to data
containing Chinese characters. The field's value become a mess after
running the SQL.

The value is submitted from an HTML form to this CGI. To verify, I
printed out the SQL statement to the output and I can see the correct
Chinese Chars been shown for the SQL statement. (Relevant codes given
below)

Then I run the sql using

$db->Sql($SQLCMD);

No errors, but the related field now contains unreadable chars.

e.g.
I tried to insert a Chi. Char having charcode = 0xA4A4
Inserted, and when I get back the value of the updated field,
the char becomes 0x3F3F, which would be a mess using ASP and Access.
And there's no linear relation between to charcodes.

Would anyone help me on this?

Thank You!

RLL

=========CODES BELOW=================
# Form-Data are put in Hash called %in. cwr contains Chinese chars.
my $value = $in;
my $rv = "";
if (defined($value)) {
if (length($value) > 0) {
for ($ic=0;$ic<length($value);$ic++) {
$px = unpack("c", substr($value, $ic, 1));
if ($px < 0) {
$ic++;
$py = unpack("c", substr($value, $ic, 1));
$px = $px + 256;
$py = $py + 256;
$px = $px * 256 + $py - 65536;
$rv .= pack("c", $px);
}
elsif (($px == 34) || ($px == 39)) { #make
SQL-Compatible string
$rv .= pack("C", $px) . pack("C", $px);
}
else {
$rv .= pack("C", $px);
}
print "$px, ";
}
print "<br>[".$rv."]<br>";
$rv = "'" . $rv . "'"; #Single-Quote it
}
else {
$rv = "NULL";
}
}
else {
$rv = "NULL";
}
print $rv; <---OK
my $SQLCMD = "update Restaurants set ChiName = " . $rv . " where Id
= 1";
print $SQLCMD; <---Also OK

$db->Sql($SQLCMD); <---Also OK

(Get back to ASP reading the database about this data, and found the
field contains messy data)


Similar ThreadsPosted
XP, Perl, Win32::ODBC, Microsoft Access 2002 SP3, & Chinese characters January 22, 2008, 4:18 pm
Module to use for win32 registry access? April 4, 2007, 8:32 pm
Dave Roth's site (Win32::AdminMisc, Win32::ODBC, etc.) not available. December 22, 2005, 8:46 am
win32::odbc October 3, 2005, 2:04 pm
Where to ask questions about Win32::ODBC? July 14, 2004, 9:36 am
Catalog() in Win32::ODBC for MySQL August 27, 2006, 1:58 am
Alternate option to win32::ODBC July 19, 2007, 2:44 pm
Alternate option to win32::ODBC July 19, 2007, 3:17 pm
Win32::ODBC Find Primary Key Column February 6, 2005, 8:21 pm
Microsoft Access & Win32::Ole October 28, 2005, 4:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap