public final class Utf8Utils
extends java.lang.Object
CONSTANT_Utf8_info.| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
escapeString(java.lang.String value) |
static byte[] |
stringToUtf8Bytes(java.lang.String string)
Converts a string into its Java-style UTF-8 form.
|
static java.lang.String |
utf8BytesToString(byte[] bytes,
int start,
int length)
Converts an array of UTF-8 bytes into a string.
|
static void |
writeEscapedChar(java.io.Writer writer,
char c) |
static void |
writeEscapedString(java.io.Writer writer,
java.lang.String value) |
public static byte[] stringToUtf8Bytes(java.lang.String string)
string - non-null; the string to convertpublic static java.lang.String utf8BytesToString(byte[] bytes,
int start,
int length)
This method uses a global buffer to avoid having to allocate one every time, so it is *not* thread-safe
bytes - non-null; the bytes to convertstart - the start index of the utf8 string to convertlength - the length of the utf8 string to convert, not including any null-terminator that might be presentpublic static void writeEscapedChar(java.io.Writer writer,
char c)
throws java.io.IOException
java.io.IOExceptionpublic static void writeEscapedString(java.io.Writer writer,
java.lang.String value)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String escapeString(java.lang.String value)