Fixes RepositoriesHelper#to_utf8 test failure for ruby1.8.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5169 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-03-20 11:14:50 +00:00 committed by Eric Davis
parent 8a0574ac5d
commit af40f86731
1 changed files with 7 additions and 0 deletions

View File

@ -154,6 +154,13 @@ module RepositoriesHelper
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