Hi, If you pass this raw QString or QByteArray somewhere, why use QUrl then? Anyway, try QUrl::fromPercentEncoding():
QUrl url("http://example.com?query=[{\"name\":\"value\"}]"); qDebug() << QUrl::fromPercentEncoding(url.toEncoded()); // produces: "http://example.com?query=[{"name":"value"}]" Cheers 2014-08-02 5:33 GMT+06:00 Lorne Sturtevant <dra...@shaw.ca>: > I am to connect to a 3rd party API over http. This API does not accept > requests that the URLs that are properly percent encoded for invalid > characters. For example. It requires urls to be of the form: > http://example.com?query=[{"name":"value"}]. > > I create the QUrl like this: > QUrl url = > QUrl::fromEncoded("http://example.com?query=[{\"name\":\"value\"}]"); > > url.toString() shows that the string is percent encoded as > http://example.com?query=[%7B%22name%22:%22value%22%7D] as it should > be. The problem is that the 3rd part API can't handle the percent > encoded form. > > I've tested this with curl as well: > curl http://example.com?query=[{"name":"value"}] returns the correct result. > curl http://example.com?query=[%7B%22name%22:%22value%22%7D] returns an > error from the 3rd party API. > > So my question is. How can I force QUrl not to percent encode the URL? > Even though it's an error, I want QUrl to ignore it and just use the raw > string I provide. > > -- > Lorne Sturtevant > Sum Ergo Cogito > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest