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

**URL:** <https://www.ruby-forum.com/t/iso-8859-1-q-from-imap-server/131176>\
**Category:** Ruby\
**Created:** [March 6, 2008, 5:56pm UTC](https://www.ruby-forum.com/t/iso-8859-1-q-from-imap-server/131176 "2008-03-06T17:56:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maria\_Almar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb9ed0/32.png) [@Maria\_Almar](https://www.ruby-forum.com/u/Maria_Almar)\
**Post date:** [March 6, 2008, 5:56pm UTC](https://www.ruby-forum.com/t/iso-8859-1-q-from-imap-server/131176/1 "2008-03-06T17:56:16Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![Maria\_Almar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb9ed0/32.png) [@Maria\_Almar](https://www.ruby-forum.com/u/Maria_Almar)\
**Post date:** [March 8, 2008, 6:54am UTC](https://www.ruby-forum.com/t/iso-8859-1-q-from-imap-server/131176/2 "2008-03-08T06:54:23Z")

</div>

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
