1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Windows: Read ENV names and values as UTF-8 encoded Strings (#3818)

* Windows: Read ENV names and values as UTF-8 encoded Strings

Implements issue #12650: fix https://bugs.ruby-lang.org/issues/12650

This also removes the special encoding for ENV['PATH'] and some
complexity in the code that is unnecessary now.

* Windows: Improve readablity of getenv() encoding

getenv() did use the expected codepage as an implicit parameter of the macro.
This is mis-leading since include/ruby/win32.h has a different definition.
Using the "cp" variable explicit (like the other function calls) makes it
more readable and consistent.

* Windows: Change external C-API macros getenv() and execv() to use UTF-8

They used to process and return strings with locale encoding,
but since all ruby-internal spawn and environment functions use UTF-8,
it makes sense to change the C-API equally.
This commit is contained in:
Lars Kanis 2020-12-07 18:00:39 +01:00 committed by GitHub
parent 94b6933d1c
commit ca76337a00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2020-12-08 02:01:05 +09:00
Merged-By: nurse <naruse@airemix.jp>
9 changed files with 39 additions and 82 deletions

View file

@ -56,7 +56,8 @@ describe "ENV.fetch" do
end
it "uses the locale encoding" do
encoding = platform_is(:windows) ? Encoding::UTF_8 : Encoding.find('locale')
ENV["foo"] = "bar"
ENV.fetch("foo").encoding.should == Encoding.find('locale')
ENV.fetch("foo").encoding.should == encoding
end
end