Class: TMail::Unquoter
- Inherits:
-
Object
- Object
- TMail::Unquoter
- Defined in:
- lib/action_mailer/vendor/tmail/quoting.rb
Class Method Summary collapse
- .unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1", preserve_underscores = false) ⇒ Object
- .unquote_base64_and_convert_to(text, to, from) ⇒ Object
- .unquote_quoted_printable_and_convert_to(text, to, from, preserve_underscores = false) ⇒ Object
Class Method Details
.unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1", preserve_underscores = false) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/action_mailer/vendor/tmail/quoting.rb', line 50 def unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1", preserve_underscores=false) return "" if text.nil? if text =~ /^=\?(.*?)\?(.)\?(.*)\?=$/ from_charset = $1 quoting_method = $2 text = $3 case quoting_method.upcase when "Q" then unquote_quoted_printable_and_convert_to(text, to_charset, from_charset, preserve_underscores) when "B" then unquote_base64_and_convert_to(text, to_charset, from_charset) else raise "unknown quoting method #{quoting_method.inspect}" end else convert_to(text, to_charset, from_charset) end end |
.unquote_base64_and_convert_to(text, to, from) ⇒ Object
74 75 76 |
# File 'lib/action_mailer/vendor/tmail/quoting.rb', line 74 def unquote_base64_and_convert_to(text, to, from) convert_to(Base64.decode(text).first, to, from) end |
.unquote_quoted_printable_and_convert_to(text, to, from, preserve_underscores = false) ⇒ Object
69 70 71 72 |
# File 'lib/action_mailer/vendor/tmail/quoting.rb', line 69 def unquote_quoted_printable_and_convert_to(text, to, from, preserve_underscores=false) text = text.gsub(/_/, " ") unless preserve_underscores convert_to(text.unpack("M*").first, to, from) end |