|
|
|
@ -23,7 +23,7 @@ module GitHelper
|
|
|
|
|
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
|
|
|
|
|
# 字符编码问题,GB18030编码识别率不行
|
|
|
|
|
decode_content =
|
|
|
|
|
if cd["encoding"] == 'GB18030' && cd['confidence'] == 1.0
|
|
|
|
|
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
|
|
|
|
|
content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
|
|
|
|
|
else
|
|
|
|
|
content.force_encoding('UTF-8')
|
|
|
|
|