T
T
tincap2015-10-02 10:54:06
Yii
tincap, 2015-10-02 10:54:06

How to fix encoding error in yii2 console?

Parsyu means profiles of people from one site. The site is Russian, and, accordingly, the usernames are also Russian.

function actionTest()
{
    $anketa = new Anketa('/* ссылка на анкету */');

    // Парсим имя пользователя
    $username = $anketa->getUsername();

    // Записываем имя в текстовик
    $anketa::recordDataInFile($username);
}

If this code is run in a browser, then the correct names will appear in the file.
And if you run this action through the console, adding the controller to app\commands, then sometimes the names are written incorrectly. For example, Mikhailovna Tamara.
There are no problems with the file. I tried to display the name on the screen, also spelled Miailovna Tamara. How to solve this problem? How to tell yii2 console to use urf-8?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Grechushnikov, 2015-10-02
@maxyc_webber

most likely your data does not come in utf8,
check the
ps. browser and console headers may be different, so check.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question