我有一个QString,其中包含编码的URL,这意味着您要将其插入浏览器的url,例如:
QString string = "http://domain.tld/index.php?some%20encoded&another%20encoded";当我创建QUrl时
QUrl(string);它随机决定什么应该编码,什么不应该,在这种情况下,它离开了“?和"&“解码,但再次编码百分比符号。因此,目标php应用程序接收“一些%20编码”而不是“一些编码”。
当QT自动尝试解析“并修复”url时,这似乎是QT的一些特性。此功能可以通过调用
QUrl(string, QUrl::StrictMode);它在qt 5+中工作得很好,但在qt 4中,尽管它进行了编译,但它的行为与我不提供StrictMode参数的行为相同。如何从我自己编码的字符串中创建url,并且不需要进一步的编码?
发布于 2013-09-25 09:31:23
你要找的是
QUrl QUrl::fromEncoded (const QByteArray &input ) [static]QUrl文档
https://stackoverflow.com/questions/19001108
复制相似问题