Subject | Re: Character Sets & Accessing Firebird using Jaybird |
---|---|
Author | Roman Rokytskyy |
Post date | 2004-06-04T13:58:11Z |
Hi,
keep in mind, and then it will be clear how to solve the issue:
- "NONE" for JayBird means: "convert byte array you get from server to
String using new String(byte[]) constructor".
- when no encoding is passed to String constructor, it will take the
system default one.
Following happens: JayBird receives data from server and converts them
into string using new String(byte[]) constructor. JVM tries to convert
data into Unicode representation and for some characters it fails and
replaces them with '?'. Why? Because default encoding for the JVM does
not have that characters. How to solve? Either set correct system-wide
character set (I suspect your JVM runs on Linux and LANG or LC_CTYPE
is "C", set it to "ISO-Latin-1") or pass it with
-Dfile.encoding=Cp1252 for example.
To verify what I'm saying you can do following: use
ResultSet.getBytes() method instead of getString() and save those byte
arrays into some file. Then open it with a java.io.Reader and check
the string you get.
Also, one of the possible issues can be that JVM works correctly, but
your terminal simply does not show such characters.
Roman
> We have a rather large Firebird database that was created a long timeThis is a bit non-trivial from the first sight. There's few things to
> ago (as an Interbase DB) using character set "NONE". We use it from
> Java 1.4.2. by means of Interclient. The data in there is actually ISO
> 8859-1 (but the DB does not know about it).
>
> We want to replace Interclient by Jaybird, but did run into a problem
> with the character sets. When connecting using character set "NONE",
> we can read and write, but any non-ASCII character seems to be ignored
> (replaced by "?"). When we indicate ISO8859_1, it tries to convert,
> which of course fails.
>
> What can we do to achieve 8-bit transparent access to the DB using
> Jaybird? Or is there a different approach that we could try?
keep in mind, and then it will be clear how to solve the issue:
- "NONE" for JayBird means: "convert byte array you get from server to
String using new String(byte[]) constructor".
- when no encoding is passed to String constructor, it will take the
system default one.
Following happens: JayBird receives data from server and converts them
into string using new String(byte[]) constructor. JVM tries to convert
data into Unicode representation and for some characters it fails and
replaces them with '?'. Why? Because default encoding for the JVM does
not have that characters. How to solve? Either set correct system-wide
character set (I suspect your JVM runs on Linux and LANG or LC_CTYPE
is "C", set it to "ISO-Latin-1") or pass it with
-Dfile.encoding=Cp1252 for example.
To verify what I'm saying you can do following: use
ResultSet.getBytes() method instead of getString() and save those byte
arrays into some file. Then open it with a java.io.Reader and check
the string you get.
Also, one of the possible issues can be that JVM works correctly, but
your terminal simply does not show such characters.
Roman