scm: for log in Ruby 1.9, replace invalid UTF-8 to '?' instead of removing.
Refer r3466 #4773. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4926 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+14
-6
@@ -253,12 +253,20 @@ class Changeset < ActiveRecord::Base
|
||||
# do nothing here
|
||||
end
|
||||
end
|
||||
# removes invalid UTF8 sequences
|
||||
begin
|
||||
Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
|
||||
rescue Iconv::InvalidEncoding
|
||||
# "UTF-8//IGNORE" is not supported on some OS
|
||||
str
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding('UTF-8')
|
||||
if ! str.valid_encoding?
|
||||
str = str.encode("US-ASCII", :invalid => :replace,
|
||||
:undef => :replace, :replace => '?').encode("UTF-8")
|
||||
end
|
||||
else
|
||||
# removes invalid UTF8 sequences
|
||||
begin
|
||||
str = Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
|
||||
rescue Iconv::InvalidEncoding
|
||||
# "UTF-8//IGNORE" is not supported on some OS
|
||||
end
|
||||
end
|
||||
str
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user