static HttpData of(Charset charset, CharSequence text) {
        requireNonNull(charset, "charset");
        requireNonNull(text, "text");

        if (text instanceof String) {
            return of(charset, (String) text);
        }

        if (text.length() == 0) {
            return empty();
        }

        final CharBuffer cb = CharBuffer.wrap(text);
        final ByteBuffer buf = charset.encode(cb);
        if (buf.arrayOffset() == 0 && buf.remaining() == buf.array().length) {
            return wrap(buf.array());
        } else {
            return copyOf(buf.array(), buf.arrayOffset(), buf.remaining());
        }
    }
Converts the specified {@code text} into an {@link HttpData}.

@param charset the {@link Charset} to use for encoding {@code text}
@param text the {@link String} to convert

@return a new {@link HttpData}. {@link #empty()} if the length of {@code text} is 0.
core/src/main/java/com/linecorp/armeria/common/HttpData.java