Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-8 issues in CodeIgniter when fetching data from mysql using codeigniter active record set

I have applied all tips/tricks available online to enable my codeigniter and mysql with utf8.

I have database and its tables with collation "utf8_unicode_ci".

In html, I have applied meta tag for utf8 : <meta charset="utf-8">

In my codeigniter instance, I have reconfirmed setting in:

config.php
`$config['charset'] = 'UTF-8'

And in database.php file, I have:

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

When I am showing records using codeigniter active record, it doesn't show utf8 decoded characters whereas when I am running native php-mysql call in same view file I can see correct characters displayed there. So this confirms that my database and html meta tag is all ok, I can sense the issue on codeigniter part where it is not calling mysql with utf8.

Does any one know how to fix this ?

Thanks.. Anjum

UPDATE: For future reference

The language was Herbew which we wanted to show on page. I changed database.php setting to:

$db['default']['char_set'] = 'latin1';
$db['default']['dbcollat'] = 'latin1_swedish_ci';
like image 204
Anjum Avatar asked May 17 '26 14:05

Anjum


1 Answers

fixed :) The language was Herbew which we wanted to be shown on page. I changed database.php setting to $db['default']['char_set'] = 'latin1'; $db['default']['dbcollat'] = 'latin1_swedish_ci'; And it works :)

like image 132
Anjum Avatar answered May 20 '26 03:05

Anjum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!