]> source.dussan.org Git - redmine.git/commitdiff
scm: fix JRuby tests fail in unit changeset following test.
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 9 Jun 2011 01:30:05 +0000 (01:30 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 9 Jun 2011 01:30:05 +0000 (01:30 +0000)
* test_invalid_utf8_sequences_in_paths_should_be_replaced

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6021 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/codeset_util.rb

index 20156b827f7c7814ef653e35752316f7de64d424..945b3ea7b1ef20b59aa6310cf75f4b2a3af0f3cf 100644 (file)
@@ -11,6 +11,13 @@ module Redmine
           str = str.encode("US-ASCII", :invalid => :replace,
                 :undef => :replace, :replace => '?').encode("UTF-8")
         end
+      elsif RUBY_PLATFORM == 'java'
+        begin
+          ic = Iconv.new('UTF-8', 'UTF-8')
+          str = ic.iconv(str)
+        rescue
+          str = str.gsub(%r{[^\r\n\t\x20-\x7e]}, '?')
+        end
       else
         ic = Iconv.new('UTF-8', 'UTF-8')
         txtar = ""