Should this be `ascii += 1 if c <= 128`? Extended ASCII is the range between 128-255, where regular ASCII is 0-127. Maybe the variable name just needs to change?

Also as I commented earlier, this will classify valid UTF-8 characters as binary I think (since they use high-bit - extended ascii range - bytes to signify muti-byte sequences). UTF-16 and UTF-32 do the same thing, but also include NULL bytes as padding which can throw off other more naive detection algorithms.

Encodings like Shift-JIS and many others also use bytes with the high bit set (>=128) to either signify a multi-byte sequence or just a higher range character not represented in the regular ASCII range. All of those will break here I think?