Encoding
-
Hello all,
I'm facing a issue related to encoding. I'm getting a response from server which contains Foreign charatcters (Chinese). I'm using QNetworkReply and reading the reply from the server. I'm on Ubuntu 14.04 machine and Qt 5.8. Instead of Chinese characters, it displays ??? symbols. Any help is greatly appreciated.
This is the snippet of the code:
@
// Reply data reading and JSON conversion
QByteArray data = reply->readAll();
QJsonParseError parsingResult;
QJsonDocument jsonDocument = QJsonDocument::fromJson(data, &parsingResult);QJsonObject jsonObject = jsonDocument.object();
qDebug() << "Seond_language" << jsonObject["second_language"].toVariant().; //op -> ???@
--nara
-
@narayanan.krish I'd check if a proper font with support for the characters you expect is available...
-
@narayanan.krish You should not verify this using qDebug. qDebug prints to console and whether the console can show such characters or not depends on its configuration. Try to put this text into QLabel or QTextEdit.
-
@jsulm ,
Thanks for the reply. I'm already exporting that variable to QML. In QML I use a Text component to display the string. Also, to confirm if this could be an encoding issue, I created a sample test console application with similar code snippet as above (Instead of readll(), I hard code the chinese characters in QByteArray). This worked and I'm able to see the Chinese characters on terminal using qDebug(). Also, can you please let me know how else I can test this ? Could it be w.r.t system configuration. If yes, any chances to check in Ubuntu 14.04 ?
--nara
-
@narayanan.krish What encoding is used to transfer this JSON?
-
@narayanan.krish I don't mean fonts. Is it UTF-8, UTF-16, ...?
-
Solved. The issue was due to missing fonts.
--nara