public class CharToByteUTF8 extends CharToByteConverter
Constructor and Description |
---|
CharToByteUTF8() |
Modifier and Type | Method and Description |
---|---|
int |
convert(char[] src,
int srcStart,
int srcEnd,
byte[] dst,
int dstStart,
int dstEnd)
Converts the specified
char array into a byte array based on
this CharToByteConverter 's encoding scheme. |
static int |
convertCharToUTF8(char[] src,
int srcStart,
byte[] dst,
int dstStart,
int len,
boolean useModifiedUTF8) |
static int |
convertStringToUTF8(String str,
int offset,
byte[] dst,
int dstStart,
int len) |
int |
flush(byte[] buff,
int start,
int length)
Tells the
CharToByteConverter to convert
any unconverted data it has internally stored. |
static int |
getCharToUTF8Length(char[] src,
int srcStart,
int len,
boolean useModifiedUTF8) |
int |
getMaxByteCount(char[] forThis,
int start,
int end)
Returns the number of bytes that the specified character
sequence will require for encoding.
|
String |
getName()
Returns the name of this encoding scheme.
|
static int |
getStringToUTF8Length(String str,
int offset,
int len) |
void |
useModifiedUTF8(boolean useMod) |
static int |
write(String str,
DataOutput writer) |
getConverter, getDefaultConverter
public static int convertCharToUTF8(char[] src, int srcStart, byte[] dst, int dstStart, int len, boolean useModifiedUTF8)
src
- ?srcStart
- ?dst
- ?dstStart
- ?len
- ?useModifiedUTF8
- ?public static int convertStringToUTF8(String str, int offset, byte[] dst, int dstStart, int len)
str
- ?offset
- ?dst
- ?dstStart
- ?len
- ?public static int getCharToUTF8Length(char[] src, int srcStart, int len, boolean useModifiedUTF8)
src
- ?srcStart
- ?len
- ?useModifiedUTF8
- ?public static int getStringToUTF8Length(String str, int offset, int len)
str
- ?offset
- ?len
- ?public int getMaxByteCount(char[] forThis, int start, int end)
CharToByteConverter
convert()
method. The value returned may not be the actual
number of converted bytes that will be produced due to
conversion errors, but it will be the maximum that will be
produced.getMaxByteCount
in class CharToByteConverter
forThis
- contains the character sequence that will be encoded
to determine the number of bytes requiredstart
- offset into the character array to begin processingend
- ending offset in the character array to end processing.
The number of processed characters will then be (end-start)
.CharToByteConverter.convert(char[],int,int,byte[],int,int)
public int convert(char[] src, int srcStart, int srcEnd, byte[] dst, int dstStart, int dstEnd) throws CharConversionException
CharToByteConverter
char
array into a byte
array based on
this CharToByteConverter
's encoding scheme. getMaxByteCount()
should
always be called first to find out how much room is required in the
destination byte array.convert
in class CharToByteConverter
src
- the same character array passed to getMaxByteCount()
srcStart
- the same starting offset as passed to getMaxByteCount()
srcEnd
- the same ending offset as passed to getMaxByteCount()
dst
- the destination byte
arraydstStart
- offset to begin storing converted characters in the
destination arraydstEnd
- the ending location for storing converted characters into the
destination array. This argument may usually be ignored, as
the algorithm may choose to continue converting characters until
finished.CharConversionException
- ?CharToByteConverter.getMaxByteCount(char[],int,int)
,
CharToByteConverter.flush(byte[],int,int)
public int flush(byte[] buff, int start, int length)
CharToByteConverter
CharToByteConverter
to convert
any unconverted data it has internally stored.
Some CharToByteConverter
's will store state between
calls to convert()
. Since the converter may be left in
an unknown state, the converter should be flushed to
notify it that no more input will be received. The converter
can handle any unfinished conversions before its output is
used.flush
in class CharToByteConverter
length
- ?buff
- the destination byte arraystart
- the next available offset into the destination arrayCharToByteConverter.convert(char[],int,int,byte[],int,int)
public String getName()
CharToByteConverter
getName
in class CharToByteConverter
public void useModifiedUTF8(boolean useMod)
useMod
- ?public static int write(String str, DataOutput writer) throws IOException
str
- ?writer
- ?IOException
- ?