code: public static String decodeString(ByteBuffer buffer, int offset, Type type) {
      int length;
      int characterCount = decodeLength(buffer, offset, type);
      offset += computeLengthOffset(characterCount, type);
      // UTF-8 strings have 2 lengths: the number of characters, and then the encoding length.
      // UTF-16 strings, however, only have 1 length: the number of characters.
      if (type == Type.UTF8) {
        length = decodeLength(buffer, offset, type);
        offset += computeLengthOffset(length, type);
      } else {
        length = characterCount * 2;
      }
      return new String(buffer.array(), offset, length, type.charset());
    }
docs: Given a buffer and an offset into the buffer, returns a String. The {@code 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.
  
  <p>Here's an example UTF-8-encoded string of ab©:
  <pre>
  03 04 61 62 C2 A9 00
  ^ Offset should be here
  </pre>
  
  @param buffer The buffer containing the string to decode.
  @param offset Offset into the buffer where the string resides.
  @param type The encoding type that the {@link ResourceString} is encoded in.
  @return The decoded string.