Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
So if you write 'H', a byte value of 48 (0100 1000) gets written. The easy way to check would be to write a server and client pair to read/write values into the streams and check them. If you need to write 16-bit Unicode, you will probably have to wrap the socket's OutputStream with a OutputStreamWriter and specify a Unicode charset that supports 16-bit characters.
If you need to write 16-bit Unicode, you will probably have to wrap the socket's OutputStream with a OutputStreamWriter and specify a Unicode charset that supports 16-bit characters.
Class Charset which OutputStreamWriter uses has UTF-16 charsets. But from what I understand, UTF-16 is a type of Unicode compression (for storage of characters in files and for transmission over the network)...and thus, it is a variable-width charset. Some characters in UTF-16 are coded in 16-bits and some 32-bits (surrogates). I need fixed-width.
If you read the documentation for Charset, it states that:
Every implementation of the Java platform is required to support the following standard charsets.
Several of which are variations on UTF-16. It goes on to state:
Consult the release documentation for your implementation to see if any other charsets are supported.
So UTF-16 is not the only choice via the Charset class. The alternatives will, of course, vary depending on your platform. Charset has an availableCharsets() method which enumerates the alternatives. An important question to ask is: what encoding does your other program expect.
Joined: Jan 29, 2003
I had Raw Bits for breakfast this morning. (That's oat hulls and wheat chaff for those who aren't long time PHC fans)
subject: Print/display the raw bits (the 1s and 0s)