]> 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:29:22 +0000 (01:29 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 9 Jun 2011 01:29:22 +0000 (01:29 +0000)
* test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis
* test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1

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

app/models/changeset.rb

index 60ab878649a55cff18ca5ac5275914bf73bf4dec..27565c6dee1adfa21362ca79c27e5ea483eaa079 100644 (file)
@@ -272,6 +272,13 @@ class Changeset < ActiveRecord::Base
                 :undef => :replace, :replace => '?').encode("UTF-8")
         end
       end
+    elsif RUBY_PLATFORM == 'java'
+      begin
+        ic = Iconv.new('UTF-8', enc)
+        str = ic.iconv(str)
+      rescue
+        str = str.gsub(%r{[^\r\n\t\x20-\x7e]}, '?')
+      end
     else
       ic = Iconv.new('UTF-8', enc)
       txtar = ""