问题
I'm facing some problems with UTF-8 and ActionMailer. My application has a form (contact) that when it is submitted, it sends an email to me. The problem is that when somebody enters some chars like öäüß, I receive the message encoded like for example
=?UTF-8?Q?funktioniert_oder_nicht.=0D=0A=0D=0Ameine_Stra=C3=9Fe_ist_die?=
=?UTF-8?Q?_Bratwurststra=C3=9Fe=0D=0A=0D=0A=C3=B6=C3=A4?=
As I understand, ActionMailer per default is utf-8 ready. Analyzing the log from my server, when the form is submitted, the params are already well encoded (it means I can read the äüö in my log)
Any idea about what should I change? should I change my application to support ISO-8859-1?
environment: ruby 1.9 and rails 3.1
回答1:
You are getting the UTF-8 bytes escaped with quoted-printable.
ß is "\xC3\x9F" -> "=C3=9F"
String#unpack('M') will decode it:
$ ruby -e 'puts "Bratwurststra=C3=9Fe=0D=0A=0D=0A=C3=B6=C3=A4".unpack "M"'
Bratwurststraße
öä
`
来源:https://stackoverflow.com/questions/8430940/utf-8-and-actionmailer