diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-23 20:45:58 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-23 20:45:58 +0000 |
commit | 6fe1243dfe71be7aea34544a7cbdd9335168bc20 (patch) | |
tree | b9a27b18d8c44f83fdc7052b325a25aa6baf6cc1 /test | |
parent | f82fd950c1a86235eb0529641f482b5a7e4ba835 (diff) |
merge revision(s) 56881: [Backport #12972]
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/branches/ruby_2_3@56887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 4efc8ca34d..4e50b350da 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -376,7 +376,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) |