Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setString() and Unicode to ASCII/ISO conversion

160765Jul 24 2002
Hi,
I encountered next problem. My database works in ISO-Latin-1 character set. Still, if I call PreparedStatement.setString(String arg) I would expect this call would convert arg parameter to ISO-Latin-1 using standard conversion mechanism. But after some testing I found out that instead of converting Java characters Oracle's driver just skips hi-byte. So if I have character with hex code 0x2019, which is absolutely normal unicode character. Oracle's driver converts it into 0x19 code, which is not even printable character and not valid ASCII code. Java's standard CharToByteConverter gives 0x63 ('?') code, which, at least, is valid ASCII/ISO-1 character.
And some soft reports "Invalid Character" errors encountering 0x19 and other such codes.

Here's a fragement from Oracle's JDBC log:
-------------
DBCV DBG2 UCS-2 bytes (10 bytes):
20 19 20 1c
DBCV FUNC DBConversion.stringToAsciiBytes(str)
DBCV DBG2 DBAccess bytes (5 bytes):
19 1c
-------------

Has anyone encountered this problem? Has anyone found work-around?
Checking and converting all strings before calls to setString() would be too overwhelming.

Thanks,
Dmitry

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2002
Added on Jul 24 2002
0 comments
439 views