Search code examples
c++qtwindowswindows-console

Set encoding for process output issue


I want to set encoding for a Windows console process for Russian ouput. In C# the Process has a StandardOutputEncoding attribute, but in Qt no such functionality exists.

Here is the problem:

enter image description here

Any suggestion how to accomplish it?

Update:

I have tried QTextStream setCodec function:

void Test1::getData(QByteArray data)
{
    QTextStream encodeStream(data);
    encodeStream.setCodec("windows-1251");

    dataTextBrowser->append(encodeStream.readAll());
    emit dataFinished();
}

Result:

enter image description here


Solution

  • Thanks to Michael O. I have fixed the issue. Also, I included the code here, so others can find the solution.

    Code:

    void Test1::getData(QByteArray data)
    {
        QTextStream encodeStream(data);
        encodeStream.setCodec("IBM 866");
        dataTextBrowser->append(encodeStream.readAll());
        emit dataFinished();
    }