You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs for the Regexp class are a bit misleading, stating for the source method "Returns the original string of the pattern." However, it appears MRI updates the source to match the encoding from encoding.
Here's an example:
MRI 2.2.2:
> ruby -v -e "r = Regexp.new('Hi', nil, 'e'); p r.encoding; p r.source.encoding"
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
-e:1: warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:US-ASCII>
MRI 1.9.3:
> ruby -v -e "r = Regexp.new('Hi', nil, 'e'); p r.encoding; p r.source.encoding"
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
-e:1: warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:US-ASCII>
JRuby 9k:
> bin/jruby -v -e "@method = :new; r = Regexp.send(@method, 'Hi', nil, 'e'); p r.encoding; p r.source.encoding"
jruby 9.0.0.0-SNAPSHOT (2.2.2) 2015-06-03 0430387 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-amd64]
-e:1: warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:UTF-8>
JRuby 1.7.20:
> ruby -v -e "r = Regexp.new('Hi', nil, 'e'); p r.encoding; p r.source.encoding"
jruby 1.7.20 (1.9.3p551) 2015-05-04 3086e6a on Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 +jit [linux-amd64]
-e:1 warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:UTF-8>
The text was updated successfully, but these errors were encountered:
nirvdrum
changed the title
Regexp's source encoding is wrong
Regexp's source's encoding is wrong
Jun 3, 2015
The docs for the Regexp class are a bit misleading, stating for the
source
method "Returns the original string of the pattern." However, it appears MRI updates thesource
to match the encoding fromencoding
.Here's an example:
MRI 2.2.2:
MRI 1.9.3:
JRuby 9k:
JRuby 1.7.20:
The text was updated successfully, but these errors were encountered: