0

I use the cakephp with SQL server 2012. In my database I have declare nvarchar instead of varchar to show the unicode. But when I use

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

the result is :

    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.

4
  • is characters ok, directly at the db? Commented May 19, 2013 at 6:01
  • it is ok, when i use sql managerment studio 2012 to query !!! Commented May 19, 2013 at 6:57
  • do you have meta tag like <meta http-equiv="Content-Type" content="text/html; charset=utf-8 "> ? Commented May 19, 2013 at 7:25
  • Yes, i already have inserted it on my meta tag ?? plz i can not find what happen ?? Commented May 19, 2013 at 7:49

1 Answer 1

1

You should change your 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 this line
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.