code: private int decodeLengthUtf8(ByteBuffer buffer) {
          int length = buffer.get();
          if ((length & 0x8000) != 0) {
              length = ((length & 0x7FFF) << 16) | buffer.get();
          } else {
              // Advance past the 2nd useless duplicate length byte.
              buffer.get();
          }
          return length;
      }
docs: (Comment taken from Android platform ResourceTypes.cpp)
  <p>
  Strings in UTF-8 format have length indicated by a length encoded in the
  stored data. It is either 1 or 2 characters of length data. This allows a
  maximum length of 0x7FFF (32767 bytes), but you should consider storing
  text in another way if you're using that much data in a single string.
  <p>
  If the high bit is set, then there are two characters or 2 bytes of length
  data encoded. In that case, drop the high bit of the first character and
  add it together with the next character.