code: private static int decodeLengthUtf16(ByteBuffer buffer) {
          int length = buffer.get();
          if ((length & 0x80) != 0) {
              length = ((length & 0x7F) << 8) | buffer.get();
          }
          return length;
      }
docs: (Comment taken from platform ResourceTypes.cpp)
  <p>
  Strings in UTF-16 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 0x7FFFFFF (2147483647 bytes), but if you're storing that
  much data in a string, you're abusing them.
  <p>
  If the high bit is set, then there are two characters or 4 bytes of length
  data encoded. In that case, drop the high bit of the first character and
  add it together with the next character.