[AOLSERVER] chinese characters and oracle driver

82 views
Skip to first unread message

Brad Chick

unread,
Jul 15, 2011, 4:01:19 PM7/15/11
to AOLS...@listserv.aol.com
I am having trouble getting Chinese characters in/out of oracle with
AOLserver. Here is my stack:

Oracle 11g
TCL 8.5
AOLserver 4.51
Oracle Driver version 2.7

The existing database has a database character set of WE8ISO8859P1.
But we are using NCHAR and NVARCHAR2 datatypes to store Unicode characters.
The
NLS_NCHAR_CHARACTERSET is properly set to AL16UTF16.

I am setting the following in the environment as an nsd wrapper:

export NLS_LANG=_.UTF8

I can login to sqlplus and insert and select chinese characters:

insert into test_zhs (foo) values (N'男孩儿男孩儿');

SQL> select * from test_zhs;

FOO
----------------------------------------------------------------------------
----
男孩儿男孩儿

I also am sure that aolserver/tcl are treating the characters appropriately.
For example, this form takes whatever characters are inputed into the form,
tries to insert them, and spits them back out.
When chinese characters are inputed, that is how the server returns them.
http://jp.xacte.com:8181/test/db/myform.tcl

On the other hand, no matter what I try, I can't get aolserver to get them
into oracle properly. I suspect it's the oracle
driver, but people have suggested that it is possible to put unicode
characters into oracle using that driver.

Any help would be way helpful.

Thanks


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

Peter Sadlon

unread,
Jul 15, 2011, 4:33:07 PM7/15/11
to AOLS...@listserv.aol.com
Just a quick shot in the dark here. 

I have ran into encoding issues in the past because by default TCL will assume everything is Latin-1 and it is not always straight forward when a conflict will happen.

You can set a variable like $first_names to be a UTF-8 string and it can be written back out as a UTF-8 string until you do something to to.  For example, do you have a wrapper that will clean a database value to prevent sqlinjection like ns_dbquotevalue?  If you do then that string's data gets converted to Latin 1.  Try something like this:

set first_names [encoding convertto "utf-8" $first_names]

Insert it into your database, something like: insert into test_zhs (foo) values ([ns_dbquotevalue $first_name]);

Check from the command line if the data is in there correctly.  If it is you will probably have some issues getting it out for the same reason.  Look at the TCL's encoding:
http://tcl.activestate.com/! man/tcl8.5/TclCmd/encoding.htm

Like I said, just a shot in the dark at what the issue may be.

_Peter


> Date: Fri, 15 Jul 2011 16:01:19 -0400
> From: br...@CHICKCENTRAL.COM
> Subject: [AOLSERVER] chinese characters and oracle driver
> To: AOLS...@LISTSERV.AOL.COM

>
> I am having trouble getting Chinese characters in/out of oracle with
> AOLserver. Here is my stack:
>
> Oracle 11g
> TCL 8.5
> AOLserver 4.51
> Oracle Driver version 2.7
>
> The existing database has a database character set of WE8ISO8859P1.
> But we are using NCHAR and NVARCHAR2 datatypes to store Unicode characters.
> The
> NLS_NCHAR_CHARACTERSET is properly set to AL16UTF16.
>
> I am setting the following in the environment as an nsd wrapper:
>
> export NLS_LANG=_.UTF8
>
> I can login to sqlplus and insert and select chinese characters:>
> insert into test_zhs (foo) values (N'男孩儿男孩儿� �З纂碣商苳�錫鮠���嗔巳苳�黼跂笏���胙闕��齡燠蓴纂碣商苳�錫鮠���届麓碣商苳�⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬⑬錫鮠���⑬⑬錫鮠���男孩儿男孩儿

>
> I also am sure that aolserver/tcl are treating the characters appropriately.
> For example, this form takes whatever characters are inputed into the form,
> tries to insert them, and spits them back out.
> When chinese characters are inputed, that is how the server returns them.
> http://jp.xacte.com:8181/test/db/myform.tcl
>
> On the other hand, no matter what I try, I can't get aolserver to get them
> into oracle properly. I suspect it's the oracle
> driver, but people have suggested that it is possible to put unicode
> characters into oracle using that driver.
>
> Any help would be way helpful.
>
> Thanks
>
>
> --
> AOLserver - http://www.aolserver.! com/

>
> To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

Janine Ohmer

unread,
Jul 15, 2011, 5:46:57 PM7/15/11
to AOLS...@listserv.aol.com
I've had to deal with Chinese Characters and Postgres.  I don't recall all the details anymore but I do recall what Peter is saying, that Tcl was a culprit more than the database.

I would use sqlplus to check what myform.tcl is inserting into the database.  That will at least tell you whether Tcl is munging it on the way in or the way out (could be both) and give you a place to start tweaking.

janine

> insert into test_zhs (foo) values (N'男孩儿男孩儿� (B');

> 
> SQL> select * from test_zhs;
> 
> FOO
> ----------------------------------------------------------------------------
> ----
> 男孩儿男孩儿
> 
> I also am sure that aolserver/tcl are treating the characters appropriately.
> For example, this form takes whatever characters are inputed into the form, 
> tries to insert them, and spits them back out. 
> When chinese characters are inputed, that is how the server returns them.
> http://jp.xacte.com:8181/test/db/myform.tcl
> 
> On the other hand, no matter what I try, I can't get aolserver to get them 
> into oracle properly. I suspect it's the oracle
> driver, but people have suggested that it is possible to put unicode 
> characters into oracle using that driver.
> 
> Any help would be way helpful.
> 
> Thanks
> 
> 
> --
> AOLserver - http://www.aolserver.! com/
> 
> To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.
-- AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

---
Janine Ohmer (formerly Sisk)
President/CEO of furfly, LLC




Reply all
Reply to author
Forward
0 new messages