Friday, August 10, 2012

The secret of UTF-8 encoding websites

There is an important meta tag when you need to do an i18n or multi-language utf-8 website. You have to put this line in HTML code <head> section:

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

There is another method. You can send HTTP header code about encoding. Here is a small PHP code as example:

header('Content-type: text/html; charset=UTF-8');

You should use both method at the same time. If you don't want mysterious invalid chars on your page use these methods all your websites. Yes, on a simple English website. You never know when would you like a new language on your site or special character. use both and you enjoy UTF-8 chars.

Have you problem with UTF-8 php mail sending? 

No comments:

Post a Comment