From: duerst via ruby-core Date: 2026-12-03T09:14:07+00:00 Subject: [ruby-core:127814] [Ruby Feature#22665] Implement Encoding#ascii_transparent? Issue #22665 has been updated by duerst (Martin D�rst). As for names, I was thinking about `Encoding#7bit_bytes_are_ASCII` and `Encoding#ASCII_is_7bit_bytes`, or something similar. The advantage is that they are understandable without an additional lookup. The problem is that method names cannot start with a digit, and both of them are a bit long. With respect to `ascii_transparent`, please note that this term doesn't turn up in the glossary at https://www.unicode.org/glossary/. Also, searching for it only turns up things like "there are no transparent characters in ASCII". But I think the main problem is making sure the documentation is clear. The earlier we start fixing the documentation for `#ascii_compatible?`, which we can do without a decision on this issue, the better. Minor nit: Please use the latest reference: https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-2/#G11174 ---------------------------------------- Feature #22665: Implement Encoding#ascii_transparent? https://bugs.ruby-lang.org/issues/22665#change-120410 * Author: byroot (Jean Boussier) * Status: Open ---------------------------------------- ### Context All Ruby encodings currently have a `#ascii_compatible?` metadata. The notion of ASCII compatibility can be a bit ambiguous, in the case of Ruby it means that ASCII text can be directly concatenated / embedded inside the string. But it doesn't mean the string can be scanned like an ASCII string. e.g. with UTF-8 if you are searching for `\` (`0x5c`) you can do a simple 1B search, but with some of the encodings currently marked as ASCII-compatible, like Shift-JS, you can't because `0x5c` is potentially a continuation byte of another character. This difference has resulted in some bugs / security vulnerability in the past, e.g. in Trilogy. ### Proposal I'd like Ruby to have the metadata necessary to distinguish these two distinct cases, so that's it's easier for Ruby code that is only ASCII aware to only accept encodings that are strict ASCII supersets. The proposed method would be `Encoding#ascii_transparent?`. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/