I have this code where tag.m_description is a QString containing Cyrillic characters: "Шщлщ"
QJsonObject json;
QJsonObject::iterator it =
json.insert("value", QJsonValue( tag.m_description );
qDebug(QJsonValue( tag.m_description ).toString());
qDebug((*it).toString());
This is the first and second output from the debug statements:
Шщлщ
⠄䤄㬄䤄
The first output is good. The second is not.
Any idea why QJsonObject::insert is corrupting my data?
I found out, looking at QJsonObject
source code, that the string is stored as a unicode string instead of utf-8. It is stored internally in a utf-16 (two byte per character) array.