OSDN Git Service

fix can not guess problem
authorSaito <saitowu@gmail.com>
Mon, 12 Dec 2011 16:41:31 +0000 (00:41 +0800)
committerJeremy Mack <jmacktdkc@gmail.com>
Tue, 13 Dec 2011 18:20:45 +0000 (13:20 -0500)
app/helpers/application_helper.rb
app/helpers/commits_helper.rb
lib/utils.rb

index 2dd652e..2f982da 100644 (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"
index ae78267..98ec993 100644 (file)
@@ -1,6 +1,4 @@
 module CommitsHelper
-  include Utils::CharEncode
-
   def old_line_number(line, i)
 
   end
index 17c9dfe..2de1476 100644 (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