php - How to show the unicode in cakephp when using SQL server -


i use cakephp sql server 2012. in database have declare nvarchar instead of varchar show unicode. when use

$this->set('types',$this->manager->query('select * product_types')) 

the result :

    array (     [0] => array         (             [0] => array                 (                     [id] => 2                     [name] => th?c u?ng c� c?n                 )          )      [1] => array         (             [0] => array                 (                     [id] => 3                     [name] => b�nh k?o                 )          )      [2] => array         (             [0] => array                 (                     [id] => 4                     [name] => x� b�ng                 )          )      [3] => array         (             [0] => array                 (                     [id] => 5                     [name] => h�ng h�a d�ng h?p                 )          )  ) 

it doesn't show unicode characters.

you should change database setting in app/config/database.php:

public $default = array(     'datasource' => 'database/mysql',     'persistent' => false,     'host' => 'localhost',     'login' => 'user',     'password' => 'password',     'database' => 'database_name',     'prefix' => '',     //'encoding' => 'utf8', ); 

to:

public $default = array(     'datasource' => 'database/mysql',     'persistent' => false,     'host' => 'localhost',     'login' => 'user',     'password' => 'password',     'database' => 'database_name',     'prefix' => '',     'encoding' => 'utf8', //uncomment line ); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -