From: "Eregon (Benoit Daloze) via ruby-core" Date: 2025-12-15T11:49:48+00:00 Subject: [ruby-core:124210] [Ruby Bug#21709] Regexp interpolation is inconsistent with String interpolation Issue #21709 has been updated by Eregon (Benoit Daloze). Right, I think Regexp interpolation should be closer to String interpolation, currently it's its own separate thing with rather weird rules. It reminds me of some other issues related to Regexp interpolation like #20407 and linked issues. ---------------------------------------- Bug #21709: Regexp interpolation is inconsistent with String interpolation https://bugs.ruby-lang.org/issues/21709#change-115693 * Author: thyresias (Thierry Lambert) * Status: Open * ruby -v: ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x64-mingw-ucrt] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- ```ruby %w(foo �tre).each do |s| puts "string: #{s.inspect} -> #{s.encoding}" puts "escaped: #{Regexp.escape(s).inspect} -> #{Regexp.escape(s).encoding}" end ``` Output: ``` string: "foo" -> UTF-8 escaped: "foo" -> US-ASCII string: "�tre" -> UTF-8 escaped: "�tre" -> UTF-8 ``` The result should always match the encoding of the argument. -- 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/