[Bug #20704] Win32: Fix chdir to non-ASCII path
On Windows, `chdir` in compilers' runtime libraries uses the active code page, but command line arguments in ruby are always UTF-8, since commit:33ea2646b98adb49ae2e1781753bf22d33729ac0.
This commit is contained in:
parent
871ba3e9e3
commit
d33e3d47b8
Notes:
git
2024-08-29 10:43:53 +00:00
2
ruby.c
2
ruby.c
@ -559,6 +559,8 @@ translit_char_bin(char *p, int from, int to)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
# undef chdir
|
||||||
|
# define chdir rb_w32_uchdir
|
||||||
# define UTF8_PATH 1
|
# define UTF8_PATH 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_kanji
|
def test_kanji
|
||||||
assert_in_out_err(%w(-KU), "p '\u3042'") do |r, e|
|
assert_in_out_err(%w(-KU), "p '\u3042'") do |r, e|
|
||||||
assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
|
assert_equal("\"\u3042\"", r.join('').force_encoding(Encoding::UTF_8))
|
||||||
end
|
end
|
||||||
line = '-eputs"\xc2\xa1".encoding'
|
line = '-eputs"\xc2\xa1".encoding'
|
||||||
env = {'RUBYOPT' => nil}
|
env = {'RUBYOPT' => nil}
|
||||||
@ -362,9 +362,20 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
|
|
||||||
d = Dir.tmpdir
|
d = Dir.tmpdir
|
||||||
assert_in_out_err(["-C", d, "-e", "puts Dir.pwd"]) do |r, e|
|
assert_in_out_err(["-C", d, "-e", "puts Dir.pwd"]) do |r, e|
|
||||||
assert_file.identical?(r.join, d)
|
assert_file.identical?(r.join(''), d)
|
||||||
assert_equal([], e)
|
assert_equal([], e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Dir.mktmpdir(d) do |base|
|
||||||
|
# "test" in Japanese and N'Ko
|
||||||
|
test = base + "/\u{30c6 30b9 30c8}_\u{7e1 7ca 7dd 7cc 7df 7cd 7eb}"
|
||||||
|
Dir.mkdir(test)
|
||||||
|
assert_in_out_err(["-C", base, "-C", File.basename(test), "-e", "puts Dir.pwd"]) do |r, e|
|
||||||
|
assert_file.identical?(r.join(''), test)
|
||||||
|
assert_equal([], e)
|
||||||
|
end
|
||||||
|
Dir.rmdir(test)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_yydebug
|
def test_yydebug
|
||||||
|
Loading…
x
Reference in New Issue
Block a user