public final class UnsafeUtf8Util extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
MAX_BYTES_PER_CHAR
Maximum number of bytes per Java UTF-16 char in UTF-8.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
decodeUtf8(byte[] bytes,
int index,
int size) |
static String |
decodeUtf8Direct(ByteBuffer buffer,
int index,
int size) |
static int |
encodedLength(CharSequence sequence)
Returns the number of bytes in the UTF-8-encoded form of
sequence. |
static int |
encodeUtf8(CharSequence in,
byte[] out,
int offset,
int length) |
static void |
encodeUtf8Direct(CharSequence in,
ByteBuffer out) |
public static final int MAX_BYTES_PER_CHAR
public static String decodeUtf8(byte[] bytes, int index, int size)
public static String decodeUtf8Direct(ByteBuffer buffer, int index, int size)
public static int encodeUtf8(CharSequence in, byte[] out, int offset, int length)
public static void encodeUtf8Direct(CharSequence in, ByteBuffer out)
public static int encodedLength(CharSequence sequence)
sequence. For a string,
this method is equivalent to string.getBytes(UTF_8).length, but is more efficient in
both time and space.IllegalArgumentException - if sequence contains ill-formed UTF-16 (unpaired
surrogates)Copyright © 2021. All rights reserved.