"\xC4" from ASCII-8BIT to UTF-8

668 views
Skip to first unread message

riverguardian

unread,
Jul 21, 2011, 1:32:55 PM7/21/11
to Ruby's Mail Discussion Group
I'm trying to read an attachment from an email received and
mail.attachments.length is giving me a correct number, so I can tell
that the attachments are there. However, when I do

File.open("public/images/" + to+"_"+from
+"_"+mail.attachments.first.filename,"w+") { |local_file|
local_file << mail.attachments.first.decoded
}

I get the following:

"\xC4" from ASCII-8BIT to UTF-8

I guess it's a bit frustrating because all the documentation
highlights how to send emails, and not parsing them

riverguardian

unread,
Jul 21, 2011, 1:42:50 PM7/21/11
to Ruby's Mail Discussion Group
For anyone who's interested, the file has to be written with format
"wb" instead of "w+".

Andrey Baiburin

unread,
Nov 24, 2012, 8:13:19 PM11/24/12
to mail...@googlegroups.com
Thanks a lot! It save my time... ;)

четверг, 21 июля 2011 г., 21:42:50 UTC+4 пользователь riverguardian написал:
Reply all
Reply to author
Forward
0 new messages