[ruby-core:96156] [Ruby master Bug#15044] ENV encoding not UTF-8 by default

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-83030.20191209102155.44b8afbd305a8dba@ruby-lang.org>
Issue #15044 has been updated by naruse (Yui NARUSE).


The assigned value to `ENV` are stored in the process's environment variable.

The encoding of `ENV[key]` is set as locale.
You can get the locale encoding by `Encoding.find("locale")` which is decided based on `Encoding.locale_charmap` which is affected by `ENV["LANG"]` and `ENV["LC_ALL"]`.

Note that `ENV["PATH"]` is returned as filesystem encoding but it is the same as locale encoding on Unix.

----------------------------------------
Bug #15044: ENV encoding not UTF-8 by default
https://bugs.ruby-lang.org/issues/15044#change-83030

* Author: lowang (Przemyslaw Wroblewski)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~
$ irb
2.5.1 :001 > 'secret'.encoding
 => #<Encoding:UTF-8>
2.5.1 :002 > ENV['PASS'] = 'secret'; ENV['PASS'].encoding
 => #<Encoding:US-ASCII>
2.5.1 :009 > ENV['PASS'] = 'Ł'
 => "\u0141"
2.5.1 :010 > ENV['PASS'].encoding
 => #<Encoding:ASCII-8BIT>
~~~
I would expect all encodings to be **UTF-8** at all times





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.