Skip to content

Encoding::ConverterNotFoundError when using Encoding.default_internal #3647

@rykov

Description

@rykov

jRuby versions affected: 9.0.4.0, 9.0.5.0 and possibly earlier ones that I didn't test.

jRuby throws an Encoding::ConverterNotFoundError error when trying to open a BOM:UTF-8 file after setting Encoding.default_internal. This does not mirror the behavior of MRI.

I was able to narrow it down to the following reproduction snippet:

# example.rb
Encoding.default_internal = 'utf-8'
File.open('empty-file', "rb:bom|utf-8") { |f| f.read }
puts "OK!"

Here are the erroneous results:

$ touch empty-file
$ rbenv shell jruby-9.0.4.0 
$ jruby ./example.rb 
Encoding::ConverterNotFoundError: code converter not found (UTF-8 to UTF-8)
...
$ rbenv shell jruby-9.0.5.0 
$ jruby ./example.rb 
Encoding::ConverterNotFoundError: code converter not found (UTF-8 to UTF-8)
...

And here's the same script working with MRI 2.2.4, 2.3.0, and jRuby 1.7.24:

$ rbenv shell 2.2.4 
$ ruby ./example.rb 
OK!
$ rbenv shell 2.3.0 
$ ruby ./example.rb 
OK!
$ rbenv shell jruby-1.7.24 
$ jruby ./example.rb 
OK!

My environment:

$ uname -a
Darwin MBA.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
$ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions