fix the issue on github #157.

directly force_encoding is wrong,
must detect the file string's encoding.
then force_encoding the string to it's encoding.
last convert it to utf-8.
This commit is contained in:
Saito 2011-11-28 17:46:41 +08:00
parent 75fa0632e6
commit 46cbe54189
5 changed files with 23 additions and 8 deletions

View file

@ -1,4 +1,5 @@
module CommitsHelper
include Utils::CharEncode
def diff_line(line, line_new = 0, line_old = 0)
full_line = html_escape(line.gsub(/\n/, ''))
color = if line[0] == "+"

View file

@ -1,4 +1,6 @@
class Commit
include Utils::CharEncode
attr_accessor :commit
attr_accessor :head
@ -20,7 +22,7 @@ class Commit
end
def safe_message
message.force_encoding(Encoding::UTF_8)
encode(message)
end
def created_at
@ -28,10 +30,10 @@ class Commit
end
def author_email
author.email.force_encoding(Encoding::UTF_8)
encode(author.email)
end
def author_name
author.name.force_encoding(Encoding::UTF_8)
encode(author.name)
end
end

View file

@ -2,7 +2,7 @@
- line_new = 0
- lines_arr = diff.diff.lines.to_a
- lines_arr.each do |line|
- line.force_encoding(Encoding::UTF_8)
- encode(line)
- next if line.match(/^--- \/dev\/null/)
- next if line.match(/^--- a/)
- next if line.match(/^\+\+\+ b/)