public class ByteUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MAX_UTF8_BYTES_PER_CHAR
Maximum number of UTF8 bytes per UTF16 character.
|
Constructor and Description |
---|
ByteUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
calcUTF16toUTF8Length(CharSequence s,
int offset,
int len)
Calculates the number of UTF8 bytes necessary to write a UTF16 string.
|
static int |
UTF16toUTF8(CharSequence s,
int offset,
int len,
byte[] result,
int resultOffset)
Writes UTF8 into the byte array, starting at offset.
|
static String |
UTF8toUTF16(byte[] utf8,
int offset,
int len)
Convert UTF8 bytes into a String
|
static int |
UTF8toUTF16(byte[] utf8,
int offset,
int len,
char[] out,
int out_offset)
Converts utf8 to utf16 and returns the number of 16 bit Java chars written.
|
static void |
UTF8toUTF16(byte[] utf8,
int offset,
int len,
CharArr out)
Convert UTF8 bytes into UTF16 characters.
|
static int |
writeUTF16toUTF8(CharSequence s,
int offset,
int len,
OutputStream fos,
byte[] scratch)
Writes UTF8 into the given OutputStream by first writing to the given scratch array
and then writing the contents of the scratch array to the OutputStream.
|
public static final int MAX_UTF8_BYTES_PER_CHAR
public static int UTF8toUTF16(byte[] utf8, int offset, int len, char[] out, int out_offset)
public static void UTF8toUTF16(byte[] utf8, int offset, int len, CharArr out)
public static String UTF8toUTF16(byte[] utf8, int offset, int len)
public static int UTF16toUTF8(CharSequence s, int offset, int len, byte[] result, int resultOffset)
public static int writeUTF16toUTF8(CharSequence s, int offset, int len, OutputStream fos, byte[] scratch) throws IOException
IOException
public static int calcUTF16toUTF8Length(CharSequence s, int offset, int len)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.