Sha256: 259bc94190364f9b7df9fbad78012a1ab2808a0de9e68cbbd385414f1e08e6d3
Contents?: true
Size: 755 Bytes
Versions: 1
Compression:
Stored size: 755 Bytes
Contents
# frozen_string_literal: true 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.config.autodetect_confidence && !Jdec.config.autodetect_skip_charsets.include?(detected[:encoding].downcase) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mail-jdec-1.2.0 | lib/mail/jdec/detector.rb |