Specail Characters

Hi everyone

I have written one function which inserts the data into database table. In some of the columns I have special characters like japanese character , El Año , ¿Cómo estás? etc like that. The query is not storing the special characters. Like in El Año it saves as “El A” so once the special char appears its cut off the rest of the word.If the word starts with special character like “¿Cómo estás?” the whole word is not getting inserted. In php query I can use this query functions i.e mysql_query(“SET NAMES ‘utf8’”); but in yii framework how to save this kind of special characters. The special character column is set as utf8_unicode_ci in database structure.

Regards

Shaik

[color=#1C2837][size=2]What is your database connection config in Yii (protected/config/main.php) ?[/size][/color]

If you did not use it try to set the charset property to utf8 - http://www.yiiframew#charset-detail

something like:




     'db' => array(

         'connectionString' => 'mysql:host=localhost;dbname=...',

         'emulatePrepare' => true,

         'username' => '...',

         'password' => '...',

         'charset' => 'utf8',

     ),

I’d guess either PHP is using the wrong character set, or the browser is using the wrong character set. Have a look at the various suggestions here and see if any of them help:

http://www.webmasterworld.com/php/3553642.htm

EDIT:

Definitely try Maurizio Domba’s suggestion first if your config’s charset isn’t set. I assumed it would be.

Domba

here is my main database file connection string

‘db’=>array(

		'connectionString' => 'mysql:host=localhost;dbname=sample',


		'emulatePrepare' => true,


		'username' => 'root',


		'password' => '....',


		'charset' => 'utf8',


	),

I have to figure it out how to insert the special chars into table through the query.

You can try to add


'initSQLs'=>array('set names utf8'),

to the configuration.

If it does not help check this wiki article for more ideas - http://www.yiiframew…set-up-unicode/