static int firstInvalidOctet(CharSequence cs, BitSet bits) {
        for (int i = 0; i < cs.length(); i++) {
            final char c = cs.charAt(i);
            if (!bits.get(c)) {
                return i;
            }
        }
        return -1;
    }
Strips out the trailing 2-char separator from the specified {@link StringBuilder}.

@param buf a buffer where some cookies were encoded.
@return the {@link String} without the trailing separator
core/src/main/java/com/linecorp/armeria/common/CookieUtil.java