Search code examples
phpmysqlcodeigniterutf-8utf8-decode

Chinese characters stored in MYSQLis not displayed in CI


I have my mysql field as collation - utf8_general_ci , when i enter the chinese characters and submit the form , it gets stored into the database fine, but when it is displayed in the view page the format differs . Below are the settings i had used

In config.php

$config['charset'] = 'UTF-8';

In database.php

$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';

And my HTML header meta tag is

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

Though i had configured all the possibilities

The chinese character displays as

中央情报局出版和更新国家的酋长和外国æâ€Â¿Ã¥ÂºÅ“的内é˜ÂæˆÂ员æ¯Â周一次的在线目录。该目录的目的是将主è¦Â作为å‚考æ´助和包括世界许多æâ€Â¿Ã¥ÂºÅ“作为被认为是实çâ€Â¨Ã¯Â¼Å’有些人没有正å¼Â被美国承认。制度与

where else in db it is stored as

中央情报局出版和更新国家的酋长和外国政府的内阁成员每周一次的在线目录。该目录的目的是将主要作为参考援助和包括世界许多政府作为被认为是实用,有些人没有正式被美国承认。制度与

I have also tried utf8_decode(); in the view page, but it also didn't work. Could anyone suggest me a solution. Thanks in advance.


Solution

  • I had included mb_internal_encoding('UTF-8'); header('Content-type: text/html; charset=UTF-8') ; in the header

    It works fine now. Thanks guys for your comments.