The input is the QString encoding of Windows-1251 . I need to write it in QVector<quint8> with the possibility of further extraction under the codec СР866 .
This option did not help.

 QByteArray msg; msg.append(strInWindows1251); QTextCodec *codec = QTextCodec::codecForName("Windows-1251"); QString res = codec->toUnicode(msg); 

Moreover, the size of the line increases (it was 8 became 15). Replacing Windows-1251 with CP866 didn't help either
Kokozyabra appears only in the presence of Cyrillic.
Thank you for your help.

    2 answers 2

    QString :: toLocal8bit will return qbytearray to you

    • Can you tell me how to deal with a resized QByteArray? for example, if the string consisted of 8 characters, then the size of QbyteArray becomes 15 - Recursive Daun
    • maybe you have Russian characters that when converted to a QString are converted to utf-8 and take up more than one byte. - Alexander

    Everything turned out to be much easier.

     QTextCodec *codec = QTextCodec::codecForName("CP866"); QByteArray baStr = codec->fromUnicode(strNewData);