ruby - rails 3 mail gem please help! -


ok have 2 emails 1 has japanese , english in both subject , body , other 1 seems in iso-8859-1

when email.subject displays both in console , browser , saves fine in database (mongodb). presume converting utf-8 properly.

problem how text_body , html_body same ?

if try save email.html_part.decoded database string not utf-8 error. if email.html_part.decoded.force_encoding("utf-8") still error. if email.html_part lets me save database not correct when viewing it.

comes out

content-type: text/plain; charset=iso-8859-1 content-transfer-encoding: quoted-printable content-id:

=0d check!=0d =0d to: joe@hotmail.com=0d subject: save =a32,000 on luxury alaskan yacht holiday! =0d from: canada@travel.co.uk=0d date: tue, 10 may 2011 05:39:24 -0500=0d =0d =0d =0d =0d =0d =0d

and japanses 1 comes out this

content-type: text/plain; charset=iso-2022-jp content-transfer-encoding: 7bit content-id:

from: joe@hotmail.com to: sales@domain.com subject: ($b%q%s$r?)$y$j$$!#(b) "i not eat bread" date: tue, 10 may 2011 21:13:55 +0000

negatives formed inflecting verb. example, pan o taberu ($b%q%s$r?)$y$k!#(b) "i eat bread" or "i eat bread" becomes pan o tabenai ($b%q%s$r?)$y$j$$!#(b) "i not eat bread" or "i not eat bread". plain negative forms i-adjectives (see below) , inflect such, e.g. pan o tabenakatta ($b%q%s$r?)$y$j$+$c$?!#(b) "i did not eat bread".

i using rails 3.0.7 , ruby 1.9.2-p180

please can ? rick

the first mail 'quoted-printable', can unpack using string#unpack:

str = "=0d check!=0d =0d to: joe@hotmail.com=0d subject: save =a32,000 on luxury alaskan yacht holiday! =0d from: canada@travel.co.uk=0d date: tue, 10 may 2011 05:39:24 -0500=0d =0d =0d =0d =0d =0d =0d".unpack('m').first => "\r check!\r \r to: joe@hotmail.com\r subject: save \xa32,000 on luxury alaskan yacht holiday! \r from: canada@travel.co.uk\r date: tue, 10 may 2011 05:39:24 -0500\r \r \r \r \r \r \r" 

you want declare iso-8859-1 , convert utf-8:

str.force_encoding('iso-8859-1').encode('utf-8') "\r check!\r \r to: joe@hotmail.com\r subject: save £2,000 on luxury alaskan yacht holiday! \r from: canada@travel.co.uk\r date: tue, 10 may 2011 05:39:24 -0500\r \r \r \r \r \r \r" 

you have same second mail.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -