diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb index 8377f1dc97..c49a18041b 100644 --- a/spec/ruby/core/dir/home_spec.rb +++ b/spec/ruby/core/dir/home_spec.rb @@ -19,6 +19,17 @@ describe "Dir.home" do it "returns a non-frozen string" do Dir.home.should_not.frozen? end + + platform_is :windows do + ruby_version_is "3.0" do + it "returns the home directory with forward slashs and as UTF-8" do + ENV['HOME'] = "C:\\rubyspäc\\home" + home = Dir.home + home.should == "C:/rubyspäc/home" + home.encoding.should == Encoding::UTF_8 + end + end + end end describe "when called with the current user name" do 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; }