code: public static ByteBuf copiedBuffer(char[] array, int offset, int length, Charset charset) {
          if (array == null) {
              throw new NullPointerException("array");
          }
          if (length == 0) {
              return EMPTY_BUFFER;
          }
          return copiedBuffer(CharBuffer.wrap(array, offset, length), charset);
      }
docs: Creates a new big-endian buffer whose content is a subregion of
  the specified {@code array} encoded in the specified {@code charset}.
  The new buffer's {@code readerIndex} and {@code writerIndex} are
  {@code 0} and the length of the encoded string respectively.