Skip to content Skip to sidebar Skip to footer

How To Handle With Foreign Languages?

I'm developing a brazilian website which has to support foreign characters like á, à, ó, í ú, ê, etc. It also uses AJAX so I thought better to use charset UTF-8 'cause I alwa

Solution 1:

Here's a really good article that helped me when I started web development. I work in a multilingual environment so I bump into this stuff constantly (just to add to how great the article was :)

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

I always make sure that my files are saved in UTF8 line encoding, that my php header files declare the charset as utf8, that my db uses utf8_general_ci for it's collation, and that my html head tag contains the meta tag declaring the content as utf8. I think that covers it.

HTH :)

edit: just to add (to be more aimed at your specific problem) check to see if your PHP code treats your results as utf8. The data might be stored correctly on the DB but could be converted when it's being served.

Solution 2:

Make sure that your database uses the UTF-8 charset AND your database connection (the encoding in which the chars are transferred between MySQL and your PHP code) is UTF-8 (see this post for reference).

Also note, that some string operations in PHP break UTF8 encoded strings ebcause they work on the assumption "1 char = byte" which is not true with UTF 8. htmlspecialchars won't work with UTF-8 encoded strings.

Solution 3:

Try changing .php file encoding - open up .php file and save it (or overwrite it) as utf8 file. Hope it helps.

Post a Comment for "How To Handle With Foreign Languages?"