digger69
unread,Jan 3, 2012, 6:49:31 PM1/3/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Core
I am using ActionMailer to parse incoming email from gmail. I found
that multi-part emails coming from Outlook clients are encoded with
charset='Windows-1252'. After creating a mail object (see
Receiver.receive() below) each part.body has charset='UTF-8' and
defaulted_charset=true. When I grab part.body.to_s the characters
aren't encoded correctly (hyphen encoded as =96 results in non-
printable char in UTF-8 string from to_s). I was assuming it would
grab the charset off the part header, but didn't see anything in
initialize that would do that (seems biased for composing email rather
than parsing existing).
Is this a limitation, defect, or just my ignorance? Thanks for any
help. As a workaround, I'm calling force_encoding() on the string and
then explicitly encoding to UTF-8.
Mark
Rails 3.0.10
class Receiver < ActionMailer::Base
def receive(email)
email
end
end