[前][次][番号順一覧][スレッド一覧]

ruby-changes:44808

From: shugo <ko1@a...>
Date: Wed, 23 Nov 2016 13:40:45 +0900 (JST)
Subject: [ruby-changes:44808] shugo:r56881 (trunk): Don't encode to UTF-8 if it's unnecessary.

shugo	2016-11-23 13:40:40 +0900 (Wed, 23 Nov 2016)

  New Revision: 56881

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56881

  Log:
    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]

  Modified files:
    trunk/test/ruby/test_dir_m17n.rb
Index: test/ruby/test_dir_m17n.rb
===================================================================
--- test/ruby/test_dir_m17n.rb	(revision 56880)
+++ test/ruby/test_dir_m17n.rb	(revision 56881)
@@ -381,7 +381,9 @@ class TestDir_M17N < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir_m17n.rb#L381
       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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]