Sha256: cedfd47966bc1d07f343577e2ff39fbf67106e0b4e3f7b2fd072f936af5d7eb1
Contents?: true
Size: 709 Bytes
Versions: 5
Compression:
Stored size: 709 Bytes
Contents
module Mail module Jdec class Detector class << self def detect(text) return if text.nil? detected = CharlockHolmes::EncodingDetector.detect(text) detected if trusty?(detected) && find_encoding(detected) end private def find_encoding(detected) Encoding.find(detected[:encoding]) rescue nil end def trusty?(detected) detected.key?(:type) && detected.key?(:encoding) && detected[:confidence].to_i > Jdec.autodetect_confidence && !Jdec.autodetect_skip_charsets.include?(detected[:encoding].downcase) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems