Class: Atig::IFilter::Utf7

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/atig/ifilter/utf7.rb

Instance Method Summary collapse

Methods included from ExceptionUtil

daemon, safe

Constructor Details

#initialize(context) ⇒ Utf7

Returns a new instance of Utf7.



10
11
12
# File 'lib/atig/ifilter/utf7.rb', line 10

def initialize(context)
  @log = context.log
end

Instance Method Details

#call(status) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/atig/ifilter/utf7.rb', line 14

def call(status)
  return status unless defined? ::Iconv and status.text.include?("+")

  status.merge :text => status.text.sub(/\A(?:.+ > |.+\z)/) { Iconv.iconv("UTF-8", "UTF-7", $&).join }
rescue Iconv::IllegalSequence
  status
rescue => e
  log :error,e
  status
end