Inserting to Oracle using Win32::ODBC

[email protected] (Stuart Green)
Newsgroups perl.unicode
Message-ID <[email protected]>
I have hit a brick wall trying to insert UTF-8 characters into Oracle 
9i from a Perl script and would appreciate any help anyone has to give.

I'm collecting user input from a web form (with UTF-8 encoding set in 
the content-type header), then trying to insert the data into an Oracle 
9i table. What is happening is...

When the user input string = "ÃÄĀāĂăàáâ", Oracle inserts 
"ÀÁÂÃÄĀāĂăàáâ" and utf8::is_utf8($user_input) returns TRUE.

    ... however ...

When the user input string = "éêëìíîïñòóôõ", Oracle inserts the correct 
string and utf8::is_utf8($user_input) returns FALSE.

In both instances, the correct string prints to the screen, so I don't 
know why Oracle inserts something different when 
utf8::is_utf8($user_input) returns TRUE .

Code is below. Thanks in advance for the help.


use utf8;
use Win32::ODBC;

$ENV{NLS_LANG} = '.UTF8';
binmode STDOUT, ":utf8";

$user_input = pack "U0C*", unpack "C*", $user_input;
utf8::decode($user_input);

$db = new Win32::ODBC("DSN=DB;UID=username;PWD=password");
$db->Sql("UPDATE TEST_TABLE SET NAME = '" . $user_input. "' WHERE ID = 
0;");

$db->Close();

print "Content-Type: text/html; charset=UTF-8\n\n";
print "<p>User entered: " . $user_input;


- Stuart Green
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.