Foreign characters turn into garbage in mysql

I am in the USA. I have the following line in my webpage:

<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 is stored in MySql as garbage. An example is e with an emphasis on it, etc. - something is not commonly used in American English. Even if someone uses a strange apostrophe, they turn it into garbage:

nation

turns into:

Nationa € ™ s

I use a regular apostrophe, but you get the idea. Foreign characters turn into 3 garbage characters. Please help! TIA

+4
source share
3 answers

Or change the title of the document to

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

or - better - change the character set of your tables to UTF-8. To do this is not entirely trivial, simply changing the sorting of the tables will not do the trick. This SO question may give some pointers.

+5
source

It seems to me that the data entered into the database is utf8. To put this in a table, it must be converted to latin1 (since this is the character set of your column), and this can result in one of three latin1 characters.

Pekka just beat me - his solution should work to fix this problem.

0
source

I remember the same case in SQlServer, I hope that it will be useful with this problem.

It has two data types: varchar [8 bits] and NVarChar [16 bits].

Now, using varchar, you cannot store 16-bit script characters such as Chines, Indic, etc., you should use the NVarchar ie data type, which can store 16-bit characters.

0
source

Source: https://habr.com/ru/post/1302382/


All Articles