diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-17 11:53:15 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-17 11:53:15 +0000 |
commit | 88f8daf8b70295957183080258f7829f8681edca (patch) | |
tree | 41ebdb863f90352e154bfa8ea959f443a0d0e90f /app/helpers/repositories_helper.rb | |
parent | fdf6e8547b6b5cb8da4ac0ae6c29377813af80bb (diff) | |
download | redmine-88f8daf8b70295957183080258f7829f8681edca.tar.gz redmine-88f8daf8b70295957183080258f7829f8681edca.zip |
move repositories helper to_utf8 logic to lib/redmine/codeset_util.rb for common use (#2371)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7825 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/repositories_helper.rb')
-rw-r--r-- | app/helpers/repositories_helper.rb | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 69f2e2558..de017ef9b 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -117,35 +117,8 @@ module RepositoriesHelper end def to_utf8(str) - return str if str.nil? - str = to_utf8_internal(str) - if str.respond_to?(:force_encoding) - str.force_encoding('UTF-8') - end - str - end - - def to_utf8_internal(str) - 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') - end - @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) - @encodings.each do |encoding| - begin - return Iconv.conv('UTF-8', encoding, str) - rescue Iconv::Failure - # do nothing here and try the next encoding - end - end - str = Redmine::CodesetUtil.replace_invalid_utf8(str) + Redmine::CodesetUtil.to_utf8_by_setting(str) end - private :to_utf8_internal def repository_field_tags(form, repository) method = repository.class.name.demodulize.underscore + "_field_tags" |