Package com.googlecode.d2j.util
Class Utf8Utils
java.lang.Object
com.googlecode.d2j.util.Utf8Utils
Constants of type
CONSTANT_Utf8_info.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringescapeString(String value) static byte[]stringToUtf8Bytes(String string) Converts a string into its Java-style UTF-8 form.static Stringutf8BytesToString(byte[] bytes, int start, int length) Converts an array of UTF-8 bytes into a string.static voidwriteEscapedChar(Writer writer, char c) static voidwriteEscapedString(Writer writer, String value)
-
Method Details
-
stringToUtf8Bytes
Converts a string into its Java-style UTF-8 form. Java-style UTF-8 differs from normal UTF-8 in the handling of character '\0' and surrogate pairs.- Parameters:
string- non-null; the string to convert- Returns:
- non-null; the UTF-8 bytes for it
-
utf8BytesToString
Converts an array of UTF-8 bytes into a string.This method uses a global buffer to avoid having to allocate one every time, so it is *not* thread-safe
- Parameters:
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 present- Returns:
- non-null; the converted string
-
writeEscapedChar
- Throws:
IOException
-
writeEscapedString
- Throws:
IOException
-
escapeString
-