]> source.dussan.org Git - redmine.git/commitdiff
scm: code clean up app/models/changeset.rb.
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 9 Apr 2011 08:19:55 +0000 (08:19 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 9 Apr 2011 08:19:55 +0000 (08:19 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5371 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/changeset.rb

index c94723ad9d9164eae905116151e223d66f140562..9248cfeee4bee7ccae378b8bd1d407e82dfa7699 100644 (file)
@@ -251,17 +251,18 @@ class Changeset < ActiveRecord::Base
       str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
       return str
     end
-    str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
     if str.respond_to?(:force_encoding)
       enc = encoding.blank? ? "UTF-8" : encoding
       if enc != "UTF-8"
         str.force_encoding(enc)
         str = str.encode("UTF-8", :invalid => :replace,
               :undef => :replace, :replace => '?')
-      end
-      if ! str.valid_encoding?
-        str = str.encode("US-ASCII", :invalid => :replace,
-              :undef => :replace, :replace => '?').encode("UTF-8")
+      else
+        str.force_encoding("UTF-8")
+        if ! str.valid_encoding?
+          str = str.encode("US-ASCII", :invalid => :replace,
+                :undef => :replace, :replace => '?').encode("UTF-8")
+        end
       end
     else
       unless encoding.blank? || encoding == 'UTF-8'