code: public static int writeAscii(ByteBuf buf, CharSequence seq) {
          // ASCII uses 1 byte per char
          final int len = seq.length();
          if (seq instanceof AsciiString) {
              AsciiString asciiString = (AsciiString) seq;
              buf.writeBytes(asciiString.array(), asciiString.arrayOffset(), len);
          } else {
              for (;;) {
                  if (buf instanceof WrappedCompositeByteBuf) {
                      // WrappedCompositeByteBuf is a sub-class of AbstractByteBuf so it needs special handling.
                      buf = buf.unwrap();
                  } else if (buf instanceof AbstractByteBuf) {
                      AbstractByteBuf byteBuf = (AbstractByteBuf) buf;
                      byteBuf.ensureWritable0(len);
                      int written = writeAscii(byteBuf, byteBuf.writerIndex, seq, len);
                      byteBuf.writerIndex += written;
                      return written;
                  } else if (buf instanceof WrappedByteBuf) {
                      // Unwrap as the wrapped buffer may be an AbstractByteBuf and so we can use fast-path.
                      buf = buf.unwrap();
                  } else {
                      byte[] bytes = seq.toString().getBytes(CharsetUtil.US_ASCII);
                      buf.writeBytes(bytes);
                      return bytes.length;
                  }
              }
          }
          return len;
      }
docs: Encode a {@link CharSequence} in <a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> and write it
  to a {@link ByteBuf}.
  
  This method returns the actual number of bytes written.