I've used Net::IMAP for the first time and all in all it worked very well. But I have one problem: When I download mails containing non-ASCII characters in the subject or the body, they are encoded using the q-encoded quoted-printable encoding scheme. How can I convert them to normal String objects? unpack("M*") does not seem to support q-encoding.
Another question: Is it possible to dump a complete mail received via Net::IMAP, so that I can feed it into RubyMail or TMail?
Cheers,
Maik
def decodeqp(str)
str.gsub(/=\?(.+?)?\?([bq])\?(.+?)\?=/i) { |x|
m = $~
case m[2].downcase # m[2] is type of encoding
when "b" then s=m[3].unpack("m*").to_s # m[3] is encoded string
when "q" then s=m[3].unpack("M*").to_s
end
case m[1].downcase # m[1] is charset
when "iso-8859-1"
...
when "iso-8859-2"
....
you might use iconv for charset conversion then
HTH (although I was demonstrated yesterday again I'm still Ruby novice)
Martin
ยทยทยท
Maik Schmidt <mschmidt@atxeu.com> wrote:
When I download mails containing non-ASCII
characters in the subject or the body, they are encoded using the
q-encoded quoted-printable encoding scheme. How can I convert them to
normal String objects? unpack("M*") does not seem to support q-encoding.