fix can not guess problem

This commit is contained in:
Saito 2011-12-13 00:41:31 +08:00
parent 822c0a5060
commit f615c877bc
3 changed files with 3 additions and 3 deletions

View file

@ -1,5 +1,6 @@
require 'digest/md5'
module ApplicationHelper
include Utils::CharEncode
def gravatar_icon(user_email)
gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com"

View file

@ -1,6 +1,4 @@
module CommitsHelper
include Utils::CharEncode
def old_line_number(line, i)
end

View file

@ -18,13 +18,14 @@ module Utils
module CharEncode
def encode(string)
return '' unless string
cd = CharDet.detect(string)
if cd.confidence > 0.6
string.force_encoding(cd.encoding)
end
string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
rescue
"Invalid code encoding"
"Invalid Encoding"
end
end