scm: fix repository helper unit test fails in Ruby 1.9 and non UTF-8 locale.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5158 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA committed 2011-03-17 03:51:46 +00:00
1 parent e27866be5b
commit 4923ff76fa
2 files changed
+14 -10

No files matched your search

+6 -7
View File
@@ -117,16 +117,15 @@ module RepositoriesHelper
end
def to_utf8(str)
return str if str.blank?
return str if str.nil?
if str.respond_to?(:force_encoding)
str.force_encoding('ASCII-8BIT')
end
return str if str.empty?
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
if str.respond_to?(:force_encoding)
str.force_encoding('UTF-8')
else
# TODO:
# Japanese Shift_JIS(CP932) is not compatible with ASCII.
# UTF-7 and Japanese ISO-2022-JP are 7bits clean.
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
end
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
@encodings.each do |encoding|
begin