Answer the question
In order to leave comments, you need to log in
Why do broken characters appear when reading data through QTextStream?
Hello. When reading data from a QByteArray by a QTextStream object, some broken character gets into the result, while the rest of the text is normal.
My method code:
void DataChannel::queryDo()
{
QByteArray bytes;
bytes.clear(); // очистка буфера
QDataStream out(&bytes, QIODevice::WriteOnly);
out << this -> httpHeader; // QString
QTextStream txt(&bytes, QIODevice::ReadOnly);
QString t = txt.readAll();
cout << this -> httpHeader.toStdString() << endl;
cout << "===========================" << endl << endl;
cout << t.toStdString() << endl; // проверка записанного текста
this -> sock -> write(bytes);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question