diff options
author | nagachika <nagachika@ruby-lang.org> | 2023-03-25 11:07:09 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2023-03-25 11:07:09 +0900 |
commit | 823835499539aa53128a025ab72eb00c288dfb09 (patch) | |
tree | b33c245f3ee3f81c89b78d98ac35d75922a24631 /win32 | |
parent | 810ae06c06312908fc1a7284773d8a9101ee145b (diff) |
merge revision(s) d6ce4180a5b4dacbac895c9911031a6df6c61136: [Backport #19243]
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.
---
spec/ruby/core/dir/home_spec.rb | 11 +++++++++++
win32/file.c | 3 ++-
2 files changed, 13 insertions(+), 1 deletion(-)
Diffstat (limited to 'win32')
-rw-r--r-- | win32/file.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/win32/file.c b/win32/file.c index 33303823b6..561d7ca346 100644 --- a/win32/file.c +++ b/win32/file.c @@ -263,10 +263,12 @@ rb_default_home_dir(VALUE result) { WCHAR *dir = rb_w32_home_dir(); if (!dir) { - rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'"); + rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'"); } append_wstr(result, dir, -1, - rb_w32_filecp(), rb_filesystem_encoding()); + rb_w32_filecp(), rb_filesystem_encoding()); + CP_UTF8, rb_utf8_encoding()); + xfree(dir); return result; } |