module Mail

Public Class Methods

b_value_decode(str) click to toggle source
# File lib/jpmobile/mail.rb, line 7
def self.b_value_decode(str)
  match = str.match(%r\=\?(.+)?\?[Bb]\?(.+)?\?\=/)
  if match
    encoding = match[1]
    str = self.decode_base64(match[2])
    str.force_encoding(fix_encoding(encoding))
  end
  # if str contains some emoticon, the following line raises Encoding error
  str.encode("utf-8", :invalid => :replace, :replace => "") rescue Jpmobile::Util.ascii_8bit(str)
end
b_value_encode(str, encoding) click to toggle source

change encoding

# File lib/jpmobile/mail.rb, line 19
def self.b_value_encode(str, encoding)
  str = Jpmobile::Util.encode(str, encoding)
  [Ruby19.encode_base64(str), encoding]
end