Decoding Quoted-printable version in ISO 8859-1 of TMail::Mail

63 views
Skip to first unread message

Naoya Makino

unread,
Dec 6, 2011, 3:07:20 PM12/6/11
to Ruby's Mail Discussion Group
I am having a trouble with decoding the unicode char of Mail::Body. If
I have a Spanish lowercase i (í) in the body of an email, it shows as
follows:

email.body
=> "Spanish lowercase i ( ? )"

I have set email encoding as follows:
email.charset
=> "iso-8859-1"
ree-1.8.7-2011.03 :004 > email.transfer_encoding
=> "quoted-printable"

so I am looking into the mail parser,

message.type
=> Mail::Message
ree-1.8.7-2011.03 :033 > message.body
=> #<Mail::Body:0x10bf93308 @preamble=nil, @raw_source="
Communications with Spanish lowercase i ( =ED ) are\r\nbreaking
parsing and truncating email after the symbol", @epilogue=nil,
@part_sort_order=["text/plain", "text/enriched", "text/html"],
@encoding="quoted-printable", @parts=[], @charset="iso-8859-1",
@boundary=nil>
ree-1.8.7-2011.03 :034 > message.charset
=> "iso-8859-1"

as you can see in the rawsource, its has a quoted-printable version of
the char.

Spanish lowercase i ( =ED )

Here is an original string of the body:

Spanish lowercase i ( í )

but when I do
message.decoded
=> " Communications with Spanish lowercase i ( ? ) are\r\nbreaking
parsing and truncating email after the symbol"

message.decode_body
=> " Communications with Spanish lowercase i ( ? ) are\r\nbreaking
parsing and truncating email after the symbol"

it does not decode properly. and by the time it gets to Mail, it shows
like above email.body with ? where Italian small i is. It did not work
when I set charset to "UTF-8" as well.
How can I decode properly? any feedbacks are appreciated.

cheers

Reply all
Reply to author
Forward
0 new messages