need help on unicode |
[eluser]daydreamer[/eluser]
I am new to php and ci. I am confused with handling unicode and hope someone could point me to the right direction. I need to migrate a website (pure procedural php+mysqli) to ci+MCV. My problem is when I get a varchar (utf8_unicode_ci) field from mysql, the result on the old website displayed is correct: Être dans les choux But on CI, the result displayed is: Être dans les choux When I use mb_detect_encoding on the results, both are UTF-8. Here are my CI config/database setting: $config['charset'] = "UTF-8"; $db['default']['dbdriver'] = "mysqli"; $db['default']['char_set'] = "utf8"; $db['default']['dbcollat'] = "utf8_unicode_ci"; And php files are saved as utf8 format Any hints to troubleshoot this? Thanks. Simple test page: test Source of ci site: controller and model: Code: class Test extends Controller { Code: <?=$event_list[0]['eventname'].' (mb_detect_encoding: '.mb_detect_encoding($event_list[0]['eventname']).')';?> Source of old site : Code: $sql = "SELECT eventname FROM event WHERE eventId=7663";
[eluser]Atharva[/eluser]
There is one setting in system/application/config/config.php file Code: $config['charset'] = "UTF-8"; Make sure it is still there.
[eluser]selinan[/eluser]
normally, set the unicode as your target language code, such as, english site use: UTF-8 is okay!
[eluser]daydreamer[/eluser]
I already put <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> in the view, the result through ci model is not the same as from php>mysqli directly. Thanks selinan.
[eluser]InsiteFX[/eluser]
Go into PhpMyAdmin click on your database name. Go and click on the operations tab. Check on the very bottom and see what your database collation is set to. When you create a new database with PhpMyAdmin it defaults to latin1_swedish_ci you need to change it to utf8_unicode_ci InsiteFX
[eluser]daydreamer[/eluser]
The database and all tables are already utf8_unicode_ci. Btw, I use CI version 1.7.3, would it be better to use version 2? Thanks InsiteFX.
[eluser]Cristian Gilè[/eluser]
Yes, CI2 provides unicode support for UTF-8 environments. Cristian Gilè
[eluser]daydreamer[/eluser]
[quote author="InsiteFX" date="1294541013"]But did you do what I said above? InsiteFX[/quote] The database, table and the field are utf8_unicode_ci, I didn't change it since I pick up the project. |
Welcome Guest, Not a member yet? Register Sign In |