Data loss when converting from QString to QByteArray
- by SleepyCod
I'm using QPlainTextEdit as an HTML editor, saving the data through an HTTP post with QNetworkAccessManager.
I experience data loss when using HTML special characters such as & (ampersand)
I'm building a POST request with a QByteArray (as mentioned in the docs).
QByteArray postData;
QMapIterator<QString, QString> i(params);
while(i.hasNext()) {
i.next();
postData
.append(i.key().toUtf8())
.append("=")
.append(i.value().toUtf8())
.append("&");
}
postData.remove(postData.length()-1, 1);
//Do request
QNetworkRequest postRequest = QNetworkRequest(res);
oManager.post(postRequest, postData);