diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-23 04:40:40 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-23 04:40:40 +0000 |
commit | 1761f8d31445a62feaafe38b5a174892ade1e0fe (patch) | |
tree | e317f1d4790b0fb4e42f3c935dde952072b03af3 /test/ruby/test_dir_m17n.rb | |
parent | 849363035f42163d22a1b5cd01212accc10e1169 (diff) | |
download | ruby-1761f8d31445a62feaafe38b5a174892ade1e0fe.tar.gz |
Don't encode to UTF-8 if it's unnecessary.
If the file system encoding is ISO-8851-1 or if the encoding of the target
string is invalid, don't encode to UTF-8. [ruby-core:78271] [Bug#12972]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_dir_m17n.rb')
-rw-r--r-- | test/ruby/test_dir_m17n.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb index 754c035ccb..5d009aceb1 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -381,7 +381,9 @@ class TestDir_M17N < Test::Unit::TestCase bug12081 = '[ruby-core:73868] [Bug #12081]' a = "*".force_encoding("us-ascii") result = Dir[a].map {|n| - if n.encoding == Encoding::ASCII_8BIT + if n.encoding == Encoding::ASCII_8BIT || + n.encoding == Encoding::ISO_8859_1 || + !n.valid_encoding? n.force_encoding(Encoding::UTF_8) else n.encode(Encoding::UTF_8) |