From b19a6d06d91252611571d2d045326daf58a3fb10 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 7 Mar 2013 08:31:58 +0000 Subject: [PATCH] move utf8 encoding from view to UnifiedDiff (#12641) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11545 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/common/_diff.html.erb | 10 +++++----- lib/redmine/unified_diff.rb | 11 ++--------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/views/common/_diff.html.erb b/app/views/common/_diff.html.erb index 94434fe86..0d30bedd2 100644 --- a/app/views/common/_diff.html.erb +++ b/app/views/common/_diff.html.erb @@ -10,7 +10,7 @@ - <%= Redmine::CodesetUtil.to_utf8_by_setting(table_file.file_name) %> + <%= table_file.file_name %> @@ -24,11 +24,11 @@ <%= line.nb_line_left %> -
<%= Redmine::CodesetUtil.to_utf8_by_setting(line.html_line_left).html_safe %>
+
<%= line.html_line_left.html_safe %>
<%= line.nb_line_right %> -
<%= Redmine::CodesetUtil.to_utf8_by_setting(line.html_line_right).html_safe %>
+
<%= line.html_line_right.html_safe %>
<% end -%> @@ -40,7 +40,7 @@ - <%= Redmine::CodesetUtil.to_utf8_by_setting(table_file.file_name) %> + <%= table_file.file_name %> @@ -55,7 +55,7 @@ <%= line.nb_line_left %> <%= line.nb_line_right %> -
<%= Redmine::CodesetUtil.to_utf8_by_setting(line.html_line).html_safe %>
+
<%= line.html_line.html_safe %>
<% end -%> diff --git a/lib/redmine/unified_diff.rb b/lib/redmine/unified_diff.rb index 9917a554f..d08ab5c01 100644 --- a/lib/redmine/unified_diff.rb +++ b/lib/redmine/unified_diff.rb @@ -30,15 +30,8 @@ module Redmine diff_table = DiffTable.new(diff_type, diff_style) diff.each do |line| line_encoding = nil - if line.respond_to?(:force_encoding) - line_encoding = line.encoding - # TODO: UTF-16 and Japanese CP932 which is imcompatible with ASCII - # In Japan, diffrence between file path encoding - # and file contents encoding is popular. - line.force_encoding('ASCII-8BIT') - end - unless diff_table.add_line line - line.force_encoding(line_encoding) if line_encoding + line = Redmine::CodesetUtil.to_utf8_by_setting(line) + unless diff_table.add_line(line) self << diff_table if diff_table.length > 0 diff_table = DiffTable.new(diff_type, diff_style) end -- 2.39.5