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
This commit is contained in:
parent
8e92ffc191
commit
b19a6d06d9
|
@ -10,7 +10,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4" class="filename">
|
<th colspan="4" class="filename">
|
||||||
<%= Redmine::CodesetUtil.to_utf8_by_setting(table_file.file_name) %>
|
<%= table_file.file_name %>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -24,11 +24,11 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th class="line-num"><%= line.nb_line_left %></th>
|
<th class="line-num"><%= line.nb_line_left %></th>
|
||||||
<td class="line-code <%= line.type_diff_left %>">
|
<td class="line-code <%= line.type_diff_left %>">
|
||||||
<pre><%= Redmine::CodesetUtil.to_utf8_by_setting(line.html_line_left).html_safe %></pre>
|
<pre><%= line.html_line_left.html_safe %></pre>
|
||||||
</td>
|
</td>
|
||||||
<th class="line-num"><%= line.nb_line_right %></th>
|
<th class="line-num"><%= line.nb_line_right %></th>
|
||||||
<td class="line-code <%= line.type_diff_right %>">
|
<td class="line-code <%= line.type_diff_right %>">
|
||||||
<pre><%= Redmine::CodesetUtil.to_utf8_by_setting(line.html_line_right).html_safe %></pre>
|
<pre><%= line.html_line_right.html_safe %></pre>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3" class="filename">
|
<th colspan="3" class="filename">
|
||||||
<%= Redmine::CodesetUtil.to_utf8_by_setting(table_file.file_name) %>
|
<%= table_file.file_name %>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<th class="line-num"><%= line.nb_line_left %></th>
|
<th class="line-num"><%= line.nb_line_left %></th>
|
||||||
<th class="line-num"><%= line.nb_line_right %></th>
|
<th class="line-num"><%= line.nb_line_right %></th>
|
||||||
<td class="line-code <%= line.type_diff %>">
|
<td class="line-code <%= line.type_diff %>">
|
||||||
<pre><%= Redmine::CodesetUtil.to_utf8_by_setting(line.html_line).html_safe %></pre>
|
<pre><%= line.html_line.html_safe %></pre>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -30,15 +30,8 @@ module Redmine
|
||||||
diff_table = DiffTable.new(diff_type, diff_style)
|
diff_table = DiffTable.new(diff_type, diff_style)
|
||||||
diff.each do |line|
|
diff.each do |line|
|
||||||
line_encoding = nil
|
line_encoding = nil
|
||||||
if line.respond_to?(:force_encoding)
|
line = Redmine::CodesetUtil.to_utf8_by_setting(line)
|
||||||
line_encoding = line.encoding
|
unless diff_table.add_line(line)
|
||||||
# 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
|
|
||||||
self << diff_table if diff_table.length > 0
|
self << diff_table if diff_table.length > 0
|
||||||
diff_table = DiffTable.new(diff_type, diff_style)
|
diff_table = DiffTable.new(diff_type, diff_style)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue