public class Charsetfunctions extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
asciiBytes(String s) |
static byte[] |
charsetBytes(String s,
String charset) |
static boolean |
isValidUTF8(ByteBuffer data)
Calling isValidUTF8 with offset 0
|
static boolean |
isValidUTF8(ByteBuffer data,
int off)
Check if the provided BytebBuffer contains a valid utf8 encoded string.
|
static String |
stringAscii(byte[] bytes) |
static String |
stringAscii(byte[] bytes,
int offset,
int length) |
static String |
stringCharset(byte[] bytes,
String charset) |
static String |
stringCharset(ByteBuffer bytes,
String charset) |
static String |
stringUtf8(byte[] bytes) |
static String |
stringUtf8(ByteBuffer bytes) |
static byte[] |
utf8Bytes(String s) |
public static byte[] utf8Bytes(String s)
public static byte[] asciiBytes(String s)
public static String stringAscii(byte[] bytes)
public static String stringAscii(byte[] bytes, int offset, int length)
public static String stringUtf8(byte[] bytes) throws InvalidDataException
public static String stringUtf8(ByteBuffer bytes) throws InvalidDataException
public static String stringCharset(byte[] bytes, String charset) throws InvalidDataException
public static String stringCharset(ByteBuffer bytes, String charset) throws InvalidDataException
public static boolean isValidUTF8(ByteBuffer data, int off)
Using the algorithm "Flexible and Economical UTF-8 Decoder" by Björn Höhrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/)
data - the ByteBufferoff - offset (for performance reasons)public static boolean isValidUTF8(ByteBuffer data)
data - the ByteBufferCopyright © 2023. All rights reserved.