CodeIgniter Forums
Problems with chinese characters - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Problems with chinese characters (/thread-49896.html)

Problems with chinese characters - El Forum - 03-06-2012

hi Guys!
i'm new here and i'm writing for a problem with chinese character and CI

I have a multilingual site with an admin zone; in admin the user can insert english and chinese text.
Admin is not in CI and everything is working. i can store and retrieve correctly chinese characters.
i save everything in utf-8 and i can save to db, retrieve correctly and see everything(text and ideograms).

In frontend: i have a demo page outside codeigniter; in this very simple php page i retrieve all data(english and chinese) and i show in a uft-8 page; everything works. i dont use anything of CI here but simple php code.

In frontend with CI: in the chinese lang file i write everything in chinese and i can see correctly the static text in every page.
the problem is when i try to retrieve chinese text from the database; the result is the utf-8 code and not ideograms.

i have utf-8 charset in the page
$config['language'] = 'english';
$config['charset'] = 'utf-8';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$active_group = 'default';
$active_record = TRUE;

The problem is that i dont see the chinese characters but the utf-8 code as here: 星期四
but if i put these chars in and i launch the decoding i can see the correct chinese characters.

it seems something wrong in the select from the db in the model or in the view, i'm using active record and the select is a "select * from mytable".
The result is a result_array and i didnt find differences from result() and result_array().
in these result set i find utf-8 elements but i cannot see ideograms in the page.

any suggestions? have i to make other conversions?

thank you very much for all guys!

Resuming, i retrieve from the model the utf8 encoding of my string... but i cannot convert in ideograms in the page...

Problems with chinese characters - El Forum - 03-07-2012

I have the same problem.
I already use the latest version of CI.
I used odbc to connect mssql

db['default']['hostname'] = "Driver={SQL Server};Server=xxxx;Database=LunchDB;AutoTranslate=yes";
$db['default']['username'] = 'sa';
$db['default']['password'] = 'xxxxx';
$db['default']['database'] = 'LunchDB';
$db['default']['dbdriver'] = 'odbc';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

When I run the following sql, the record shows ????. However, it should be chinese characters.
$this->db->select("Lunch_Day1_SetA_ch as day1_a");
$query = $this->db->get();
if ($query->num_rows() < 1) {
log_message("debug","No lunch record");
return FALSE;
$this->menu_records = $query->row();

How to solve it?

Problems with chinese characters - El Forum - 03-08-2012

Things to try:

$sql = "ALTER TABLE $table DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";


$this->db->query("SET NAMES 'UTF8'");

Problems with chinese characters - El Forum - 06-10-2013

Hello to you InsiteFX

I'm newbie in CI world.

Thanks for you above solution for MySQL database, It's work like charm!

Would you mind, how if the database is in MS-SQL Server 2005.

Please help and thanks in advance