Module: ACSV::Detect::EncodingUChardet

Defined in:
lib/acsv-p/detect/encoding_uchardet.rb

Constant Summary collapse

DEFAULT_CONFIDENCE =
0.01

Class Method Summary collapse

Class Method Details

.encoding(data, options) ⇒ Object



20
21
22
23
24
25
# File 'lib/acsv-p/detect/encoding_uchardet.rb', line 20

def self.encoding(data, options)
  if present?
    encdet = ::ICU::UCharsetDetector.detect(data)
    encdet[:encoding] if encdet[:confidence] > (options[:confidence] || DEFAULT_CONFIDENCE)*100
  end
end

.present?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/acsv-p/detect/encoding_uchardet.rb', line 16

def self.present?
  defined? ::ICU::UCharsetDetector
end

.require_nameObject



12
13
14
# File 'lib/acsv-p/detect/encoding_uchardet.rb', line 12

def self.require_name
  'uchardet'
end