?ISO-8859-1?Q? from IMAP server

Hi all,

I have an encoding problem when a want to examine my mails from an IMAP
server.
Strings with “special characters” are returned with the
“?ISO-8859-1?Q?” prefix and special characters are messed up (“é”
becomes “=E9”)

Do I have to call IMAP with special parameters ?
Or can I convert this string afterward ?

Login to the Imap server

imap = Net::IMAP.new(‘imap.gmail.com’, 993, true)
imap.login(name, password)

Examine the INBOX box

imap.examine(“INBOX”)

Fetch a single message

msg = imap.uid_fetch([123], [‘ENVELOPE’])[0]
puts msg.attr[“ENVELOPE”].subject

=> =?ISO-8859-1?Q?Invitation_to_join_XXX_from_Nicolas_F=E9tiou?=

I’m on Leopard, and tried with “irb” and “irb --noreadline”

Regards

Maria

Not messed up, just encoded to work with SMTP. The mail protocol wasn’t
really designed with i18n in mind, so it doesn’t support unicode or
anything other than the regular latin charset for the header items. The
body is usually handled as MIME, so it get’s encoded to avoid issues.

What your seeing is an encoding applied to the mail headers. the mail
client needs to do the conversion to something readable/usable by it.
The first portion specifies the character set encoding used. The Q
specifies the encoding method used.

I’d suggest reading the rfc’s on mail handing and internationalization
of mail headers.
hth.
–mg