diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-04-16 06:43:49 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-04-16 06:43:49 +0000 |
commit | a78b12706a46670e3c07f37e379cb67f725038ac (patch) | |
tree | c6d0bf44b7ad58fcfcba6d0fe306ca9f367e2d41 /app/helpers | |
parent | 2507bcd8e7f83de07c6360f41e2fdf9ea5c96db2 (diff) | |
download | redmine-a78b12706a46670e3c07f37e379cb67f725038ac.tar.gz redmine-a78b12706a46670e3c07f37e379cb67f725038ac.zip |
add Redmine::CodesetUtil and move replacing invalid utf8 logic to it.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5474 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/repositories_helper.rb | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 9037b39f1..fb1d4dd05 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'iconv' +require 'redmine/codeset_util' module RepositoriesHelper def format_revision(revision) @@ -143,35 +144,10 @@ module RepositoriesHelper # do nothing here and try the next encoding end end - str = replace_invalid_utf8(str) + str = Redmine::CodesetUtil.replace_invalid_utf8(str) end private :to_utf8_internal - def replace_invalid_utf8(str) - return str if str.nil? - 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 - ic = Iconv.new('UTF-8', 'UTF-8') - txtar = "" - begin - txtar += ic.iconv(str) - rescue Iconv::IllegalSequence - txtar += $!.success - str = '?' + $!.failed[1,$!.failed.length] - retry - rescue - txtar += $!.success - end - str = txtar - end - str - end - def repository_field_tags(form, repository) method = repository.class.name.demodulize.underscore + "_field_tags" if repository.is_a?(Repository) && |