Modifier and Type | Class and Description |
---|---|
static class |
TextCodecObject.InsertStripCRIndexes |
Modifier and Type | Field and Description |
---|---|
static int |
ADD_CR_ALWAYS
This is a creation option.
|
static int |
ADD_CR_PLATFORM_DEPENDENT
This is a creation option to be used with either of the other ADD_CR_XXX options.
|
static int |
ADD_CR_SMART
This is a creation option.
|
static int |
IGNORE_ENDIAN_MARKER_ON_DECODE |
static int |
MUST_HAVE_ENDIAN_MARKER_ON_DECODE |
static int |
STRIP_CR
This is a creation option.
|
static int |
STRIP_CR_ON_DECODE
This is a creation option.
|
static int |
STRIP_CR_ON_ENCODE
This is a creation option.
|
static int |
WRITE_ENDIAN_MARKER_ON_ENCODE |
Constructor and Description |
---|
Utf16Codec(boolean bigEndianByDefault,
int options)
Create a Utf16Codec that will default to either big-endian byte encoding or
little-endian byte encoding unless
a Byte Order Marker (BOM) is present as the first two bytes, in which case
the BOM will determine the endianess (endianity?)
|
Modifier and Type | Method and Description |
---|---|
void |
closeCodec()
This aborts any on-going processing and frees resources associated with the codec.
|
CharArray |
decodeText(byte[] encodedText,
int start,
int length,
boolean endOfData,
CharArray dest)
Decode the bytes into Unicode characters.
|
ByteArray |
encodeText(char[] text,
int start,
int length,
boolean endOfData,
ByteArray dest)
Enocde the Unicode characters into a byte Stream.
|
Object |
getCopy()
This should return a new instance of the TextCodec, ready to begin converting a new set of
data.
|
protected TextCodecObject.InsertStripCRIndexes |
insertStripCR(char[] src,
int offset,
int length) |
static boolean |
platformUsesCRforNewLine()
Return true if the underlying platform uses CR with a new line.
|
void |
reset()
Reset the codec for both input and output.
|
public static final int MUST_HAVE_ENDIAN_MARKER_ON_DECODE
public static final int WRITE_ENDIAN_MARKER_ON_ENCODE
public static final int IGNORE_ENDIAN_MARKER_ON_DECODE
public static final int STRIP_CR_ON_DECODE
public static final int STRIP_CR_ON_ENCODE
public static final int STRIP_CR
public static final int ADD_CR_SMART
public static final int ADD_CR_ALWAYS
public static final int ADD_CR_PLATFORM_DEPENDENT
public Utf16Codec(boolean bigEndianByDefault, int options)
If the MUST_HAVE_ENDIAN_MARKER_ON_DECODE option is specified then the marker must be present as the first two bytes in the encoded stream. If the IGNORE_ENDIAN_MARKER_ON_DECODE option is specified then the marker is ignored and the endianess is always determined by bigEndianByDefault.
On encoding the endianess will be as specified by the bigEndianByDefault parameter and a BOM marker will be written if the WRITE_ENDIAN_MARKER_ON_ENCODE option is specified.
bigEndianByDefault
- if true the codec will default to being big-endian,
if false the codec will default to being little-endian.options
- any of the class constants values OR'ed together.public ByteArray encodeText(char[] text, int start, int length, boolean endOfData, ByteArray dest) throws IOException
TextCodec
text
- The characters to encode. This can be null if length is zero and endOfData is true. You
would use those settings to tell the codec that no more characters are to be encoded and
the final set of output bytes (if any) should be output.start
- The start of the characters in the text array.length
- The number of characters to encode.endOfData
- If this is true this tells the codec that no more characters are to be
encoded and the final set of output bytes (if any) should be output.dest
- A ByteArray to hold the output data. The output data is appended to the data member and
and the length member holds how many bytes were output.IOException
- if an error occurs during encoding.public CharArray decodeText(byte[] encodedText, int start, int length, boolean endOfData, CharArray dest) throws IOException
TextCodec
encodedText
- The encoded bytes. This can be null if length is zero and endOfData is true. You
would use those settings to tell the codec that no more characters are to be decoded and
the final set of decoded characters (if any) should be output.start
- The start of the bytes in the byte array.length
- The number of bytes to decode.endOfData
- If this is true this tells the codec that no more characters are to be decoded and
the final set of decoded characters (if any) should be output.dest
- A CharArray to hold the output data. The output data is appended to the data member and
and the length member will be updated to indicate how many bytes were appended.IOException
- if an error occurs during decoding, including badly formatted data.public void closeCodec() throws IOException
TextCodec
IOException
public Object getCopy()
TextCodec
public void reset()
TextCodec
public static boolean platformUsesCRforNewLine()
protected TextCodecObject.InsertStripCRIndexes insertStripCR(char[] src, int offset, int length)