Reputation: 5282
I am trying to write a C++ Qt 4.7 app that gets some JSON from a web API. I have done some reading and JsonCpp seems to be the best. So I built it just find and added it to my project just fine.
void RetrievingInformationPage::replyFinished(QNetworkReply *reply)
{
Json::Value root;
Json::Reader reader;
bool success = reader.parse(reply->readAll().data(), root);
// here be issues
qDebug() << QString::fromStdString(root["data"][30]["name"].toStyledString());
return;
}
When I run this code, it outputs the name I am testing (it is a name with unicode in it) but the special characters output as complete gibberish ("à¤?à¥à¤²à¤¿à¤«à¤°à¥à¤¡"). The unicode went in as a JSON string "\u0915\u094d\u0932\u093f\u092b\u0930\u094d\u0921", then I assume JsonCpp converts it into the actual unicode characters. I was hoping that QString::fromStdString would take unicode in a std::string and store it in a QString, but clearly it is messing up somewhere.
What am I missing?
Upvotes: 4
Views: 1817