It is possible to specify the encoding that Java will use to handle characters.
Internally everything is handled via 16bit characters, but external java can handle ASCII just as well as Unicode.
We had a similar problem where data passed from a Java program over a socket to a piece of legacy hardware that could only cope with 8 bit characters was recieving it.
Code:
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream(),Charset.forName(US_ACSII)));
This above piece of code meant that all of the characters and strings that went out over the socket from the Java code were ASCII based.
The charsets that Java currently support are -
US-ASCII - Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.
ISO-8859-1 - ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 UTF-8 Eight-bit UCS Transformation Format.
UTF-16BE - Sixteen-bit UCS Transformation Format, big-endian byte order.
UTF-16LE - Sixteen-bit UCS Transformation Format, little-endian byte order.
UTF-16 - Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark.
Plus Java being Java it is possible to create your own charsets.
Check out the Java Documentation on the classes
and
----------------------------------------
There are no onions, only magic
----------------------------------------