Given:
“\x80”.force_encoding(“ASCII-8BIT”).encode( Encoding::Emacs_Mule)
raises an Encoding::ConverterNotFoundError on all rubies
On all rubies except for mri 2.1 and 2.2, encoding with the invalid
option has no effect. But on 2.1 and 2.2, it replaces the “\x80” ==
128.chr with the replace string (‘?’, 63.chr)
for each ruby version with UTF-8 encoding
[“1.9.2”, “ruby”, #Encoding:UTF-8, #Encoding:UTF-8, 128]
[“1.9.3”, “ruby”, #Encoding:UTF-8, #Encoding:UTF-8, 128]
[“2.0.0”, “ruby”, #Encoding:UTF-8, #Encoding:UTF-8, 128]
[“2.1.5”, “ruby”, #Encoding:UTF-8, #Encoding:UTF-8, 63]
[“2.2.0”, “ruby”, #Encoding:UTF-8, #Encoding:UTF-8, 63]
[“2.0.0”, “jruby”, #Encoding:UTF-8, #Encoding:UTF-8, 128]
[“2.1.0”, “rbx”, #Encoding:UTF-8, #Encoding:UTF-8, 128]
[“1.9.3”, “jruby”, #Encoding:UTF-8, #Encoding:UTF-8, 128]
[“2.0.0”, “jruby”, #Encoding:UTF-8, #Encoding:UTF-8, 128]
Here’s my test code
LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
rvm
ruby-1.9.2-p330,ruby-1.9.3-p551,ruby-2.0.0-p598,ruby-2.1.5,ruby-2.2.0,jruby-1.7.18,rbx-2.2.2
do
ruby -e ‘p [RUBY_VERSION, RUBY_ENGINE, Encoding.default_external,
ENCODING] +
“\x80”.force_encoding(“ASCII-8BIT”).force_encoding(“Emacs-Mule”).encode(:invalid
=> :replace).bytes.to_a’
for version in 1.9 2.0; do
export JRUBY_OPTS=“-Xcompat.version=${version}” ;
LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
rvm jruby-1.7.18 do
ruby -e ‘p [RUBY_VERSION, RUBY_ENGINE, Encoding.default_external,
ENCODING] +
“\x80”.force_encoding(“ASCII-8BIT”).force_encoding(“Emacs-Mule”).encode(:invalid
=> :replace).bytes.to_a’ ; done
For the particularly curious, this is relevant to a PR I have for
rspec-support