diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-02 07:58:24 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-02 07:58:24 +0000 |
commit | f9ac2106bf0835c836bd48e82680908f5dfab233 (patch) | |
tree | 880f56b8150328745bccd90b333b183dbff13276 /test/ruby | |
parent | 6bbd9104cbd1e1229a5c61a5e4498dc9b1a03239 (diff) |
file.c: use filesystem encoding
* file.c (rb_realpath_internal): use filesystem encoding if the
argument is in ASCII encodings.
* win32/file.c (rb_readlink): needs the result encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_file.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 8335b78760..d7507b4661 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -258,6 +258,26 @@ class TestFile < Test::Unit::TestCase } end + def test_realpath_encoding + fsenc = Encoding.find("filesystem") + nonascii = "\u{0391 0410 0531 10A0 05d0 2C00 3042}" + tst = "A" + nonascii.each_char {|c| tst << c.encode(fsenc) rescue nil} + Dir.mktmpdir('rubytest-realpath') {|tmpdir| + realdir = File.realpath(tmpdir) + open(File.join(tmpdir, tst), "w") {} + a = File.join(tmpdir, "a") + File.symlink(tst, a) + assert_equal(File.join(realdir, tst), File.realpath(a)) + File.unlink(a) + + tst = "A" + nonascii + open(File.join(tmpdir, tst), "w") {} + File.symlink(tst, a) + assert_equal(File.join(realdir, tst), File.realpath(a.encode("UTF-8"))) + } + end + def test_realdirpath Dir.mktmpdir('rubytest-realdirpath') {|tmpdir| realdir = File.realpath(tmpdir) |