mirror of
https://github.com/ruby/ruby.git
synced 2025-09-22 20:14:02 +02:00
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
This commit is contained in:
parent
a7a1391fc9
commit
2411cab586
1 changed files with 3 additions and 1 deletions
|
@ -381,7 +381,9 @@ class TestDir_M17N < Test::Unit::TestCase
|
||||||
bug12081 = '[ruby-core:73868] [Bug #12081]'
|
bug12081 = '[ruby-core:73868] [Bug #12081]'
|
||||||
a = "*".force_encoding("us-ascii")
|
a = "*".force_encoding("us-ascii")
|
||||||
result = Dir[a].map {|n|
|
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)
|
n.force_encoding(Encoding::UTF_8)
|
||||||
else
|
else
|
||||||
n.encode(Encoding::UTF_8)
|
n.encode(Encoding::UTF_8)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue