code: public static ByteBuf writeUtf8(ByteBufAllocator alloc, CharSequence seq) {
          // UTF-8 uses max. 3 bytes per char, so calculate the worst case.
          ByteBuf buf = alloc.buffer(utf8MaxBytes(seq));
          writeUtf8(buf, seq);
          return buf;
      }
docs: Encode a {@link CharSequence} in <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> and write
  it to a {@link ByteBuf} allocated with {@code alloc}.
  @param alloc The allocator used to allocate a new {@link ByteBuf}.
  @param seq The characters to write into a buffer.
  @return The {@link ByteBuf} which contains the <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> encoded
  result.