Problems with character encoding (UTF-8 vs ISO-8859-1)

Whenever I need to do something in HTML, PHP and / or MySQL, here comes the problem of character encoding!

In MySQL coding I use is utf8_general_ci and use HTML charset = UTF-8.

At the outset, it seems that everything should go well!

It turns out that by default when the connection is made to MySQL, the used charset is latin1, which soon spoils the view of the characters (special).

The best solution I got was to put the following statement, following the definition of the database connection (mysql_connect):

# mysql_set_charset ('utf8', $ link);

If you do not use this queisram solution and just want to change the display of one or another variable, one can use the following instructions:

# utf8_encode ($ string);

# htmlentities ($ string);

Normally I use xampp for Linux (lampp) to program these platforms, but must also occur in other (even Windows users). This happens to me always to the point of me going through with this, so today I decided to spend one hour of my life researching with feet and head on this.

The character encoding is a subject that gives cloth sleeves! Anyway I think these statements in PHP already help a lot.


0

0 comentários:

Etiquetas

Seguidores

Ocorreu um erro neste dispositivo

Popular Posts