UTF8 Character encoding with PHP/Apache CMS, CodeIgniter, MYSQL

I’ve encountered a lot of questions about how to display Multi-byte (non Latin) characters such as Japanese, Korean Chinese Characters.
I’d like to share you this solution to save your time fixing this problem.

the most basic solution here is to make sure you set your character encoding to UTF-8 in all areas of your application.

  • In Apache – Edit the php.ini file and edit the Content Type, set [default_charset="UTF-8"]  which is usually located in
    • Windows – C:/wamp/bin/php/php.verion_no/oho.ini
    • Linux  – /etc/php.ini

 

  • PHP/HTML Document – don’t forget to set your header content type <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />

 

  • In Codeigniter config.php set the charset to $config['charset'] = ‘UTF-8′;

 

  • In Codeigniter  database.php set $db['default']['char_set'] = ‘utf8′; and $db['default']['dbcollat'] = ‘utf8_general_ci’;

 

  • MySQL Database  properties set Defualt Character Set to UTF-8 and default Collation to utf8_gneral_ci

That’s it! I hope this solution works for you. if you have questions, don’t hesitate to drop your comments


 

Comments

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
= 5 + 2