Package org.jf.util
Class Utf8Utils
java.lang.Object
org.jf.util.Utf8Utils
Constants of type
CONSTANT_Utf8_info.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]stringToUtf8Bytes(String string) Converts a string into its Java-style UTF-8 form.private static StringthrowBadUtf8(int value, int offset) Helper forutf8BytesToString(byte[], int, int), which throws the right exception for a bogus utf-8 byte.static Stringutf8BytesToString(byte[] bytes, int start, int length) Converts an array of UTF-8 bytes into a string.static Stringutf8BytesWithUtf16LengthToString(byte[] bytes, int start, int utf16Length) Converts an array of UTF-8 bytes into a string.static Stringutf8BytesWithUtf16LengthToString(byte[] bytes, int start, int utf16Length, int[] readLength) Converts an array of UTF-8 bytes into a string.
-
Field Details
-
localBuffer
-
-
Constructor Details
-
Utf8Utils
public Utf8Utils()
-
-
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.- 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
-
utf8BytesWithUtf16LengthToString
public static String utf8BytesWithUtf16LengthToString(@Nonnull byte[] bytes, int start, int utf16Length) Converts an array of UTF-8 bytes into a string.- Parameters:
bytes- non-null; the bytes to convertstart- the start index of the utf8 string to convertutf16Length- the number of utf16 characters in the string to decode- Returns:
- non-null; the converted string
-
utf8BytesWithUtf16LengthToString
public static String utf8BytesWithUtf16LengthToString(@Nonnull byte[] bytes, int start, int utf16Length, @Nullable int[] readLength) Converts an array of UTF-8 bytes into a string.- Parameters:
bytes- non-null; the bytes to convertstart- the start index of the utf8 string to convertutf16Length- the number of utf16 characters in the string to decodereadLength- If non-null, the first element will contain the number of bytes read after the method exits- Returns:
- non-null; the converted string
-
throwBadUtf8
Helper forutf8BytesToString(byte[], int, int), which throws the right exception for a bogus utf-8 byte.- Parameters:
value- the byte valueoffset- the file offset- Returns:
- never
- Throws:
IllegalArgumentException- always thrown
-