code: @Override
    public void encodeUtf8(CharSequence in, ByteBuffer out) {
      if (out.hasArray()) {
        int start = out.arrayOffset();
        int end = encodeUtf8Array(in, out.array(), start + out.position(),
            out.remaining());
        out.position(end - start);
      } else {
        encodeUtf8Buffer(in, out);
      }
    }
docs: Encodes the given characters to the target {@link ByteBuffer} using UTF-8 encoding.
  
  <p>Selects an optimal algorithm based on the type of {@link ByteBuffer} (i.e. heap or direct)
  and the capabilities of the platform.
  
  @param in the source string to be encoded
  @param out the target buffer to receive the encoded string.