Issue #18576 has been updated by Eregon (Benoit Daloze).
@naruse Do you have evidence of (latest release and not ancient) gems or applications
comparing `encoding.name` to `'ASCII-8BIT'`?
I think it's so obviously a bad idea to compare the encoding name as a String, AFAIK
there was never a valid reason to use it (over `enc == Encoding::BINARY`, which works
since Ruby 1.9) and it's inefficient, brittle and unnecessary.
FWIW
https://github.com/search?q=%22name+%3D%3D+%27ASCII-8BIT%27%22&type=cod…
shows very few matches and it's mostly copies of old VCR code.
The chance of that code running on Ruby 3.4+ seems almost nonexistent, there would likely
be many more serious compatibility issues with such old code (e.g. kwargs changes).
And fixing it is really easy.
@matz Can we experiment for 3.4?
If we have pushback based on actual code then let's go more conservative, but
otherwise I think we should do the clean fix here.
----------------------------------------
Feature #18576: Rename `ASCII-8BIT` encoding to `BINARY`
https://bugs.ruby-lang.org/issues/18576#change-106183
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* Target version: 3.4
----------------------------------------
### Context
I'm now used to it, but something that confused me for years was errors such as:
```ruby
> "fée" + "\xFF".b
(irb):3:in `+': incompatible character encodings: UTF-8 and ASCII-8BIT
(Encoding::CompatibilityError)
```
When you aren't that familiar with Ruby, it's really not evident that `ASCII-8BIT`
basically means "no encoding" or "binary".
And even when you know it, if you don't read carefully it's very easily confused
with `US-ASCII`.
The `Encoding::BINARY` alias is much more telling IMHO.
### Proposal
Since `Encoding::ASCII_8BIT` has been aliased as `Encoding::BINARY` for years, I think
renaming it to `BINARY` and then making asking `ASCII_8BIT` the alias would significantly
improve usability without backward compatibility concerns.
The only concern I could see would be the consistency with a handful of C API functions:
- `rb_encoding *rb_ascii8bit_encoding(void)`
- `int rb_ascii8bit_encindex(void)`
- `VALUE rb_io_ascii8bit_binmode(VALUE io)`
But that's for much more advanced users, so I don't think it's much of a
concern.
--
https://bugs.ruby-lang.org/