fix can not guess problem
This commit is contained in:
parent
2201ef8020
commit
a1cd582c67
3 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue