Forum: Ruby on Rails Question re: Charactersets

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tom H. (Guest)
on 2009-01-26 00:47
Hi there,

I need some help with characters (charactersets):

I have "special characters" in some db fields. When those fields are
used for the composition of an email, those "special characters" show up
screwed up in the email text, for example:

- a 'ü' in my db becomes a 'ü' in the email body.
- a 'é' in my db becomes a 'é' in the email body.

I suppose this has something to do with the choice of the charactersets,
but I don't know where the "bug" exactly lies...

in phpMyAdmin, I can see that
- MySQL charset:  UTF-8 Unicode (utf8)

Furthermore, I have set the following to "latin1_general_ci":
- MySQL connection collation
- the collation of the entire db
- the collation of all tables
- the collation of all columns (that have the type "varchar")

And: I used to check that my
charset/collation "latin1_general_ci" really *contains* the characters
needed (ö, ü, é, etc.), so I think that must be the right choice.

Thank you for any help with this!
Tom H. (Guest)
on 2009-01-26 01:38
Ok, here's the issue, in case anyone is interested

The email client used was Thunderbird. And Thunderbird uses by default
the following encoding:

Western ISO-8859
...also known as...
ISO 8859-2 Central European

So the MySQL db needed to use the same encoding or "the corresponding
collation" (which is "latin2_general_ci") in order to encode special
characters such as 'ü' or 'é' correctly.


Tom H. (Guest)
on 2009-01-26 02:48
Plus, the mailer model needed one more line:

def my_mail()
  charset    "latin1"     # -> tell it to use Western ISO-8859 encoding
  from       blah
  recipients blah
  subject    blah
This topic is locked and can not be replied to.