Methods
- convert_to
- convert_to
- unquote_and_convert_to
- unquote_base64_and_convert_to
- unquote_quoted_printable_and_convert_to
Public Class methods
Not providing quoting support
[ show source ]
# File lib/action_mailer/vendor/tmail/quoting.rb, line 94
94: def convert_to(text, to, from)
95: warn "Action Mailer: iconv not loaded; ignoring conversion from #{from} to #{to} (#{__FILE__}:#{__LINE__})"
96: text
97: end
[ show source ]
# File lib/action_mailer/vendor/tmail/quoting.rb, line 80
80: def convert_to(text, to, from)
81: return text unless to && from
82: text ? Iconv.iconv(to, from, text).first : ""
83: rescue Iconv::IllegalSequence, Errno::EINVAL
84: # the 'from' parameter specifies a charset other than what the text
85: # actually is...not much we can do in this case but just return the
86: # unconverted text.
87: #
88: # Ditto if either parameter represents an unknown charset, like
89: # X-UNKNOWN.
90: text
91: end
[ show source ]
# File lib/action_mailer/vendor/tmail/quoting.rb, line 50
50: def unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1", preserve_underscores=false)
51: return "" if text.nil?
52: if text =~ /^=\?(.*?)\?(.)\?(.*)\?=$/
53: from_charset = $1
54: quoting_method = $2
55: text = $3
56: case quoting_method.upcase
57: when "Q" then
58: unquote_quoted_printable_and_convert_to(text, to_charset, from_charset, preserve_underscores)
59: when "B" then
60: unquote_base64_and_convert_to(text, to_charset, from_charset)
61: else
62: raise "unknown quoting method #{quoting_method.inspect}"
63: end
64: else
65: convert_to(text, to_charset, from_charset)
66: end
67: end
[ show source ]
# File lib/action_mailer/vendor/tmail/quoting.rb, line 74
74: def unquote_base64_and_convert_to(text, to, from)
75: convert_to(Base64.decode(text).first, to, from)
76: end
[ show source ]
# File lib/action_mailer/vendor/tmail/quoting.rb, line 69
69: def unquote_quoted_printable_and_convert_to(text, to, from, preserve_underscores=false)
70: text = text.gsub(/_/, " ") unless preserve_underscores
71: convert_to(text.unpack("M*").first, to, from)
72: end