class ByteBufUtil {

    public static int utf8Bytes(final CharSequence seq) {
        if (seq instanceof AsciiString) {
            return seq.length();
        }
        int seqLength = seq.length();
        int i = 0;
        // ASCII fast path
        while (i < seqLength && seq.charAt(i) < 0x80) {
            ++i;
        }
        // !ASCII is packed in a separate method to let the ASCII case be smaller
        return i < seqLength ? i + utf8Bytes(seq, i, seqLength) : i;
    }

    private  ByteBufUtil();

}