Hi,
I'm trying to read a string in Utf8 encoding from binary file through using QDataStream.
Binary file has some records like this:
06000000D098D0BCD18F
06000000D098D0BCD18F
To copy to clipboard, switch view to plain text mode
where
06000000 - quint32, text data size in bytes,
D098D0BCD18F - text in utf8, just a 3 chars in russian
I'm trying to do like this:
...
quint32 labelLen;
in >> labelLen;
qDebug() << "labelLen=" << labelLen;
char * label = new char [labelLen];
in.readRawData(label, labelSize);
qDebug() << "label=" << label;
QDataStream in(&file);
...
quint32 labelLen;
in >> labelLen;
qDebug() << "labelLen=" << labelLen;
char * label = new char [labelLen];
in.readRawData(label, labelSize);
qDebug() << "label=" << label;
To copy to clipboard, switch view to plain text mode
But as a result in console I'm getting some unreadable data, not a text...
How to read a data correctly and convert readed a text data to QString?
Bookmarks