• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with chinese characters

#1
[eluser]Unknown[/eluser]
hi Guys!
i'm new here and i'm writing for a problem with chinese character and CI

SITUATION
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.

CONFIG
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 http://software.hixie.ch/utilities/cgi/u...f8-decoder 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!

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

#2
[eluser]Unknown[/eluser]
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");
$this->db->from("Lunch");
$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?


#3
[eluser]InsiteFX[/eluser]
Things to try:
Code:
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

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

$this->db->set_charset('utf8');

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

#4
[eluser]Unknown[/eluser]
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

Regards,
Steven


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.