@@ -22,12 +22,20 module Redmine | |||||
22 | options.assert_valid_keys(:type, :max_lines) |
|
22 | options.assert_valid_keys(:type, :max_lines) | |
23 | diff = diff.split("\n") if diff.is_a?(String) |
|
23 | diff = diff.split("\n") if diff.is_a?(String) | |
24 | diff_type = options[:type] || 'inline' |
|
24 | diff_type = options[:type] || 'inline' | |
25 |
|
||||
26 | lines = 0 |
|
25 | lines = 0 | |
27 | @truncated = false |
|
26 | @truncated = false | |
28 | diff_table = DiffTable.new(diff_type) |
|
27 | diff_table = DiffTable.new(diff_type) | |
29 | diff.each do |line| |
|
28 | diff.each do |line| | |
|
29 | line_encoding = nil | |||
|
30 | if line.respond_to?(:force_encoding) | |||
|
31 | line_encoding = line.encoding | |||
|
32 | # TODO: UTF-16 and Japanese CP932 which is imcompatible with ASCII | |||
|
33 | # In Japan, diffrence between file path encoding | |||
|
34 | # and file contents encoding is popular. | |||
|
35 | line.force_encoding('ASCII-8BIT') | |||
|
36 | end | |||
30 | unless diff_table.add_line line |
|
37 | unless diff_table.add_line line | |
|
38 | line.force_encoding(line_encoding) if line_encoding | |||
31 | self << diff_table if diff_table.length > 1 |
|
39 | self << diff_table if diff_table.length > 1 | |
32 | diff_table = DiffTable.new(diff_type) |
|
40 | diff_table = DiffTable.new(diff_type) | |
33 | end |
|
41 | end | |
@@ -40,7 +48,7 module Redmine | |||||
40 | self << diff_table unless diff_table.empty? |
|
48 | self << diff_table unless diff_table.empty? | |
41 | self |
|
49 | self | |
42 | end |
|
50 | end | |
43 |
|
51 | |||
44 | def truncated?; @truncated; end |
|
52 | def truncated?; @truncated; end | |
45 | end |
|
53 | end | |
46 |
|
54 |
General Comments 0
You need to be logged in to leave comments.
Login now