-1

I am working on multisite language that is in yii2, I have chinese and japanese language in it, When i insert record with chinese or japanese it is added with ????? , i have added
header('Content-Type: text/html; charset=UTF-8');

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

in layouts/main.php file but still in database added character as ????,

I have other solution to change charset to utf-8 for each column in database But this will be take too much time
Is there any simple way to solve this ?

Nikul
  • 465
  • 1
  • 8
  • 24
  • Refer: http://stackoverflow.com/questions/1045338/which-is-the-best-character-encoding-for-japanese-language-for-db-php-and-html – Insane Skull Jan 04 '16 at 06:30

1 Answers1

1

Configure db in yii to use utf-8 character set.

'components' => [
    'db' => [
        'class' => '\yii\db\Connection',
        'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
        'username' => 'root',
        'password' => '',
        'charset' => 'utf8',
    ],
], 

Go to your phpmyadmin selected the table where you want chinese and japnense words to be inserted and set the property 'collation' to utf8_general_ci and now you can insert those words and it will get stored in database as chinese itself.

Bloodhound
  • 2,906
  • 11
  • 37
  • 71