Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Foreign characters turn into garbage in mysql

I am in the U.S. I have the following line in my web page:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

And my MYSQL table is MyISAM latin1_swedish_ci

But when someone fills out a form with a foreign character it gets stored in MySql as garbage. An example would be an e with accent over it, etc. - something not normally used in American English. Even if someone uses a weird apostrophe, its get turned into garbage:

nation's

gets turned into:

nation’s

I'm using a regular apostrophe there but you get the idea. Foreign characters turn into 3 garbage characters. Please help! TIA

like image 323
Alexia Avatar asked Feb 25 '10 16:02

Alexia


1 Answers

Either change your document's header to

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

or - better - change your tables' character set to UTF-8. To do that is not entirely trivial, just changing the tables' collation won't do the trick. This SO question might give some pointers.

like image 170
Pekka Avatar answered Oct 03 '22 07:10

Pekka