Commit f615c877bcb36aa2e4bc399545376671b55f167e

Authored by Saito
1 parent 822c0a50

fix can not guess problem

app/helpers/application_helper.rb
1 1 require 'digest/md5'
2 2 module ApplicationHelper
  3 + include Utils::CharEncode
3 4  
4 5 def gravatar_icon(user_email)
5 6 gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com"
... ...
app/helpers/commits_helper.rb
1 1 module CommitsHelper
2   - include Utils::CharEncode
3   -
4 2 def old_line_number(line, i)
5 3  
6 4 end
... ...
lib/utils.rb
... ... @@ -18,13 +18,14 @@ module Utils
18 18  
19 19 module CharEncode
20 20 def encode(string)
  21 + return '' unless string
21 22 cd = CharDet.detect(string)
22 23 if cd.confidence > 0.6
23 24 string.force_encoding(cd.encoding)
24 25 end
25 26 string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
26 27 rescue
27   - "Invalid code encoding"
  28 + "Invalid Encoding"
28 29 end
29 30 end
30 31  
... ...