public final class UTF8 extends Object
Strings.| Modifier and Type | Method and Description |
|---|---|
static boolean |
canDecode(byte... input)
Returns whether the given byte array represents valid UTF-8 encoded
characters.
|
static boolean |
canDecode(byte[] input,
int off,
int len)
Returns whether the specified range in the given byte array represents
valid UTF-8 encoded characters.
|
static boolean |
canEncode(String str)
Returns whether the given
String can be encoded into UTF-8. |
static boolean |
canEncode(String str,
int off,
int len)
Returns whether the specified range in the given
String can
be encoded into UTF-8. |
static String |
decode(byte... input)
Decodes the given UTF-8 encoded characters.
|
static String |
decode(byte[] input,
int off,
int len)
Decodes
len UTF-8 encoded bytes from the given input buffer,
starting at off. |
static byte[] |
encode(String str)
Returns the UTF-8 encoding of the given
String. |
static byte[] |
encode(String str,
int off,
int len)
Returns the UTF-8 encoding of the specified character sequence.
|
public static boolean canEncode(String str)
String can be encoded into UTF-8.str - the String to test.str can be encoded into UTF-8.NullPointerException - if str is null.public static boolean canEncode(String str, int off, int len)
String can
be encoded into UTF-8.str - the input String.off - the start index, inclusive.len - the number of characters to test.str can be encoded
into UTF-8.NullPointerException - if str is null.IndexOutOfBoundsException - if off or len is
negative or if off + len is greater than str's
length.public static boolean canDecode(byte... input)
input - the bytes to test.input repesents UTF-8 encoded characters.NullPointerException - if input is null.public static boolean canDecode(byte[] input,
int off,
int len)
input - the input buffer.off - the start index, inclusive.len - the number of bytes to test.input represents UTF-8
encoded characters.NullPointerException - if input is null.IndexOutOfBoundsException - if off or len is
negative or if off + len is greater than input's
length.public static byte[] encode(String str)
String.str - the String to encode.String.NullPointerException - if str is null.IllegalArgumentException - if str can't be encoded into
UTF-8.public static byte[] encode(String str, int off, int len)
str - the input String.off - the start index, inclusive.len - the number of characters to encode.NullPointerException - if str is null.IndexOutOfBoundsException - if off or len is
negative or if off + len is greater than str's
length.IllegalArgumentException - if str can't be encoded into
UTF-8.public static String decode(byte... input)
input - the UTF-8 encoded characters to decode.NullPointerException - if input is null.IllegalArgumentException - if input doesn't represent
valid UTF-8 encoded characters.public static String decode(byte[] input, int off, int len)
len UTF-8 encoded bytes from the given input buffer,
starting at off.input - the input buffer.off - the starting offset.len - the number of bytes to decode.NullPointerException - if input is null.IndexOutOfBoundsException - if off or len is
negative or if off + len is greater than input's
length.IllegalArgumentException - if input doesn't represent
valid UTF-8 encoded characters.Copyright © 2012–2015. All rights reserved.