Issue #20466 has been reported by tenderlovemaking (Aaron Patterson).
----------------------------------------
Bug #20466: Interpolated regular expressions have different encoding than interpolated
strings
https://bugs.ruby-lang.org/issues/20466
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
When the encoding is set to US-ASCII, interpolated strings can have different encoding
than interpolated regular expressions. I think they should have the same encoding:
```ruby
# encoding: US-ASCII
t0 = '\\xc1'
t1 = "#{t0}"
re = /#{t0}/
p [t0.encoding, t1.encoding, re.encoding]
```
Output is:
```
$ ./miniruby -v test.rb
ruby 3.4.0dev (2024-05-02T15:27:18Z master 7c0cf71049) [arm64-darwin23]
[#<Encoding:US-ASCII>, #<Encoding:US-ASCII>, #<Encoding:BINARY
(ASCII-8BIT)>]
```
--
https://bugs.ruby-lang.org/