Java Reference
In-Depth Information
Each of these methods puts more than one byte in the buffer, moving the current position
forward the same number of bytes.
There also are methods to retrieve nonbytes from a byte buffer: getChar() ,
getDouble() , getFloat() , getInt() , getLong() , and getShort() .
Character Sets
Character sets, which are offered in the java.nio.charset package, are a set of classes
used to convert data between byte buffers and character buffers.
The three main classes are
Charset —A Unicode character set with a different byte value for each different
character in the set
n
Decoder —A class that transforms a series of bytes into a series of characters
n
Encoder —A class that transforms a series of characters into a series of bytes
n
Before you can perform any transformations between byte and character buffers, you
must create a CharSet object that maps characters to their corresponding byte values.
To create a character set, call the forName( String ) static method of the Charset class,
specifying the name of the set's character encoding.
Java includes support for six character encodings:
US-ASCII —The 128-character ASCII set that makes up the Basic Latin block of
Unicode (also called ISO646-US)
n
ISO-8859-1 —The 256-character ISO Latin Alphabet No. 1.a. character set (also
called ISO-LATIN-1)
n
UTF-8 —A character set that includes US-ASCII and the Universal Character Set
(also called Unicode), a set comprising thousands of characters used in the world's
languages
n
UTF-16BE —The Universal Character Set represented as 16-bit characters with
bytes stored in big-endian byte order
n
UTF-16LE —The Universal Character Set represented as 16-bit characters with
bytes stored in little-endian byte order
n
UTF-16 —The Universal Character Set represented as 16-bit characters with the
order of bytes indicated by an optional byte-order mark
n
Search WWH ::




Custom Search