Question re: Charactersets


#1

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 http://www.collation-charts.org/mysql60/ 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


#2

Ok, here’s the issue, in case anyone is interested
(internationalization…):

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.

(http://dev.mysql.com/doc/refman/5.1/en/charset-charsets.html)

Tom


#3

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
etc…
end