Module: DTAS::Encoding

Included in:
DTAS
Defined in:
lib/dtas/encoding.rb

Overview

This module gets included in DTAS

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(mod) ⇒ Object

:nodoc:



7
8
9
# File 'lib/dtas/encoding.rb', line 7

def self.extended(mod)
  mod.instance_eval { @charlock_holmes = nil}
end

Instance Method Details

#try_enc(str, enc, harder = true) ⇒ Object

:nodoc:



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/dtas/encoding.rb', line 45

def try_enc(str, enc, harder = true) # :nodoc:
  old = str.encoding
  return str if old == enc
  str.force_encoding(enc)
  unless str.valid_encoding?
    if harder
      try_enc_harder(str, enc, old)
    else
      enc_fallback(str, enc, old)
    end
  end
  str
end