Skip to content

JRuby not using UTF-8 for source files #2847

@nirvdrum

Description

@nirvdrum

MRI seems to always use UTF-8 by default when loading source files. This is used by the lexer & parser, but doesn't update the runtime's encoding. JRuby, on the other hand, seems to always use whatever the default_external encoding is, which is influenced by the system's locale.

$ cat enc.rb
p Encoding.default_external
p __ENCODING__

$ LC_ALL=C bin/jruby -v enc.rb 
jruby 9.0.0.0-SNAPSHOT (2.2.1) 2015-04-17 7b6475d Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-amd64]
#<Encoding:US-ASCII>
#<Encoding:US-ASCII>

$ LC_ALL=C ruby -v enc.rb 
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
#<Encoding:US-ASCII>
#<Encoding:UTF-8>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions