Forum: Ruby on Rails imap and character enconding

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
34459577b182f43fafb9c11177fffa43?d=identicon&s=25 Felipe Cruxen (fcruxen)
on 2007-03-13 15:29
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', 'username@domain.com', 'password')
    imap.select('INBOX')
    @emails = []
    imap.search(["ALL"]).each do |i|
      @emails << imap.fetch(i, "ENVELOPE")[0].attr["ENVELOPE"]
    end
    imap.disconnect
end

VIEW =>
<h1>Webmail#list_inbox</h1>
  <% @emails.each do |i| %>
        <%= i.from[0].name %> / <%= i.subject %><br />
    <% 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.
Bd0e3475228f1e39ca7ab03968461a6f?d=identicon&s=25 Pete Yandell (Guest)
on 2007-03-15 06:39
(Received via mailing list)
On 14/03/2007, at 1:29 AM, Felipe Cruxen 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 Yandell
http://notahat.com/
This topic is locked and can not be replied to.