public final class BinaryResourceString
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
BinaryResourceString.Type
Type of
BinaryResourceString to encode / decode. |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
decodeString(java.nio.ByteBuffer buffer,
int offset,
BinaryResourceString.Type type)
Given a buffer and an offset into the buffer, returns a String.
|
static byte[] |
encodeString(java.lang.String str,
BinaryResourceString.Type type)
Encodes a string in either UTF-8 or UTF-16 and returns the bytes of the encoded string.
|
public static java.lang.String decodeString(java.nio.ByteBuffer buffer,
int offset,
BinaryResourceString.Type type)
offset is the
0-based byte offset from the start of the buffer where the string resides. This should be the
location in memory where the string's character count, followed by its byte count, and then
followed by the actual string is located.
Here's an example UTF-8-encoded string of ab©:
03 04 61 62 C2 A9 00 ^ Offset should be here
buffer - The buffer containing the string to decode.offset - Offset into the buffer where the string resides.type - The encoding type that the BinaryResourceString is encoded in.public static byte[] encodeString(java.lang.String str,
BinaryResourceString.Type type)
Here's an example UTF-8-encoded string of ab©:
03 04 61 62 C2 A9 00
str - The string to be encoded.type - The encoding type that the BinaryResourceString should be encoded in.