Imap and character enconding


#1

Hi, hi, hi little droogies

First of all, sorry for the lame english and the dumb question. After a
quick search on google I found iconv, and some other toys, but the point
is:

I’m making a small webmail app for my company, still taking the first
steps. For instance, if I want to read my INBOX folder and list the
messages:


CONTROLLER =>
def list_inbox
imap = Net::IMAP.new(‘xxx.xxx.xxx.xxx’)
imap.authenticate(‘LOGIN’, ‘removed_email_address@domain.invalid’, ‘password’)
imap.select(‘INBOX’)
@emails = []
imap.search([“ALL”]).each do |i|
@emails << imap.fetch(i, “ENVELOPE”)[0].attr[“ENVELOPE”]
end
imap.disconnect
end

VIEW =>

Webmail#list_inbox


<% @emails.each do |i| %>
<%= i.from[0].name %> / <%= i.subject %>

<% end %>

The enconding seems messed up, when the message comes in iso-8859-1
format, it’s preceeded with “=?iso-8859-1?Q?”, same for utf-8
“=?UTF-8?Q?”. And the accents come encoded too (=E9 => é).How can I
solve this?

Thanks in advance.


#2

On 14/03/2007, at 1:29 AM, Felipe C. wrote:

The enconding seems messed up, when the message comes in iso-8859-1
format, it’s preceeded with “=?iso-8859-1?Q?”, same for utf-8
“=?UTF-8?Q?”. And the accents come encoded too (=E9 => é).How can I
solve this?

That’s the way non-ASCII headers are supposed to be encoded. You need
to read:

http://www.ietf.org/rfc/rfc2047.txt

Cheers,

Pete Y.
http://notahat.com/