Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Do Win32::ODBC module support Chinese characters when used with MS Access?
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{'cwr'};
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)

Report this thread to moderator Post Follow-up to this message
Old Post
Rico Lopez Liparte
09-16-04 09:52 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:09 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.