Reputation: 1
I'm trying to capture some data via a web service and I encounter the following problem. By getting strings that contain special characters ("Español") the text obtained is incorrect ("Espa\u00f1ol").
I tried verified data arriving at the service with wireshark and correct. Data arriving show "Español".
The code I use is currently as follows:
QNetworkRequest req ( url );
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QNetworkReply *reply = this->wsClient->get( req );
QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
SLOT(onError(QNetworkReply::NetworkError)));
QEventLoop loop;
connect(this->wsClient, SIGNAL(finished(QNetworkReply *)), &loop,SLOT(quit()));
loop.exec();
if (this->pRespNetwork->error() == QNetworkReply::NoError){
QString jsonData(this->pRespNetwork->readAll());
qDebug() << jsonData;
}
I hope you can help me.
Thank You.
Upvotes: 0
Views: 436
Reputation: 9465
In your main.cpp add the following line: (Assuming Qt 4)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
Upvotes: 1