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. --- include/ruby/win32.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/ruby/win32.h') diff --git a/include/ruby/win32.h b/include/ruby/win32.h index b29470b0c4..b3b8b47fe3 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -160,7 +160,7 @@ typedef int clockid_t; #define Sleep(msec) (void)rb_w32_Sleep(msec) #undef execv -#define execv(path,argv) rb_w32_aspawn(P_OVERLAY,path,argv) +#define execv(path,argv) rb_w32_uaspawn(P_OVERLAY,path,argv) #undef isatty #define isatty(h) rb_w32_isatty(h) @@ -717,7 +717,7 @@ extern char *rb_w32_strerror(int); #define getcwd(b, s) rb_w32_getcwd(b, s) #undef getenv -#define getenv(n) rb_w32_getenv(n) +#define getenv(n) rb_w32_ugetenv(n) #undef rename #define rename(o, n) rb_w32_rename(o, n) -- cgit v1.2.3