From d6ce4180a5b4dacbac895c9911031a6df6c61136 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sun, 18 Dec 2022 21:05:22 +0100 Subject: Windows: Fix encoding of Dir.home Dir.home returns an UTF-8 string since ruby-3.0, but the actual encoding of the bytes was CP_ACP or CP_OEMCP. That led to invalid bytes when calling Dir.home with an unicode username. --- win32/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'win32') diff --git a/win32/file.c b/win32/file.c index e047144d36..31cc1aff6e 100644 --- a/win32/file.c +++ b/win32/file.c @@ -266,7 +266,8 @@ rb_default_home_dir(VALUE result) rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'"); } append_wstr(result, dir, -1, - rb_w32_filecp(), rb_filesystem_encoding()); + CP_UTF8, rb_utf8_encoding()); + xfree(dir); return result; } -- cgit v1.2.3