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 | acdd2be4a83ec607422c9cdabbaa98c129bbb512 (patch) | |
tree | 880f56b8150328745bccd90b333b183dbff13276 /test/ruby | |
parent | 02f0acb1936c9938d9557cf13f8ff5a0657bb103 (diff) | |
download | ruby-acdd2be4a83ec607422c9cdabbaa98c129bbb512.tar.gz |
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) |