From ca76337a00244635faa331afd04f4b75161ce6fb Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Mon, 7 Dec 2020 18:00:39 +0100 Subject: 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. --- test/ruby/test_m17n.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'test/ruby/test_m17n.rb') diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 2c6dc3f8f5..3f28d55ac1 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1325,10 +1325,14 @@ class TestM17N < Test::Unit::TestCase end def test_env - locale_encoding = Encoding.find("locale") + if RUBY_PLATFORM =~ /bccwin|mswin|mingw/ + env_encoding = Encoding::UTF_8 + else + env_encoding = Encoding.find("locale") + end ENV.each {|k, v| - assert_equal(locale_encoding, k.encoding, k) - assert_equal(locale_encoding, v.encoding, v) + assert_equal(env_encoding, k.encoding, k) + assert_equal(env_encoding, v.encoding, v) } end -- cgit v1.2.3