module Mail::Jenc::UnstructuredFieldPatch

Public Class Methods

new(name, value, charset = nil) click to toggle source
Calls superclass method
# File lib/mail/jenc/fields/unstructured_field_patch.rb, line 4
def initialize(name, value, charset = nil)
  if Jenc.enabled?
    if value.is_a?(String) && value.encoding == Encoding::UTF_8 && charset && charset.downcase != 'utf-8'
      if !value.ascii_only?
        value = Mail::Encodings.b_value_encode(
          Mail::Encodings.transcode_charset(value, value.encoding, charset)
        )
      elsif value !~ Mail::Encodings::ENCODED_VALUE
        charset = 'us-ascii'
      end
    end
  end
  super
end