Mercurial > hg > soundsoftware-site
diff lib/redmine/.svn/text-base/unified_diff.rb.svn-base @ 246:eeebe205a056 cannam
* Merge from default branch, bringing us up to SVN trunk rev 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 12:02:03 +0000 |
parents | 051f544170fe |
children | cbce1fd3b1b7 |
line wrap: on
line diff
--- a/lib/redmine/.svn/text-base/unified_diff.rb.svn-base Thu Jan 20 09:59:02 2011 +0000 +++ b/lib/redmine/.svn/text-base/unified_diff.rb.svn-base Thu Mar 03 12:02:03 2011 +0000 @@ -22,13 +22,21 @@ options.assert_valid_keys(:type, :max_lines) diff = diff.split("\n") if diff.is_a?(String) diff_type = options[:type] || 'inline' - lines = 0 @truncated = false diff_table = DiffTable.new(diff_type) 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 - self << diff_table if diff_table.length > 1 + line.force_encoding(line_encoding) if line_encoding + self << diff_table if diff_table.length > 0 diff_table = DiffTable.new(diff_type) end lines += 1 @@ -40,7 +48,7 @@ self << diff_table unless diff_table.empty? self end - + def truncated?; @truncated; end end