My environment is, aka my current locale, iso-8859-1, so the results that
I get seem correct. I can change the UTF-8 default encoding if I use a
shebang line in the .rb file, which I normally do, so all my encodings are
the same (ISO-8859-1; regexes used to behave a bit oddly sometimes but I
am not sure if that has changed or not).
I think ENV behaves a litle bit differently upon an
assignment.
If I use a shebang line in a .rb file that includes the above unicode
character (this weird L), then all string encodings in that .rb file
are also ISO-8859-1, so I am not sure if there is any bug at all.
It may be more related to IRB perhaps? I skipped testing on IRB mostly
because .rb files have a "higher weight" than code put through IRB.
The documentation does not mention what happens with encodings when
these are assigned to an ENV key, though:
And of course it may be that there is indeed a bug. You can try to
test with a standalone .rb file though and, if necessary, with a
specific shebang comment.
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.