summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-03-25 11:07:09 +0900
committernagachika <nagachika@ruby-lang.org>2023-03-25 11:07:09 +0900
commit823835499539aa53128a025ab72eb00c288dfb09 (patch)
treeb33c245f3ee3f81c89b78d98ac35d75922a24631 /spec
parent810ae06c06312908fc1a7284773d8a9101ee145b (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 'spec')
-rw-r--r--spec/ruby/core/dir/home_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb
index 713ba9db9a..e8c7f5970b 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