From: "byroot (Jean Boussier) via ruby-core" Date: 2026-12-02T06:38:15+00:00 Subject: [ruby-core:127792] [Ruby Feature#22665] Implement Encoding#ascii_superset? Issue #22665 has been updated by byroot (Jean Boussier). > sing Ruby should first and foremost use operations on Strings that work independently of the underlying representation, rather than trying to be clever, and leave the details of the encoding to Ruby itself Yes, I wasn't implying the issue was with Ruby itself, it was in C extensions where using Ruby strings wasn't possible. What I'm requesting is a helpful metadata for these cases. > Second, we should update the documentation Yes, definitely. > As for your proposed method name, ascii_superset?, I'm not sure I like it Right, I'm not convinced it's the best name either, I'm more than open to suggestions. ---------------------------------------- Feature #22665: Implement Encoding#ascii_superset? https://bugs.ruby-lang.org/issues/22665#change-120389 * 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_superset?`. -- 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/