Bug #20466 open
Interpolated regular expressions have different encoding than interpolated strings
Added by tenderlovemaking (Aaron Patterson) over 2 years ago.
Description
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:
# 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)>]
Related to Misc #20407 : Question about applying encoding modifier to an interpolated Regexp added
Also available in: PDF
Atom