结论
我做了一些研究,到目前为止的结论是:荒谬的.
QUrl :: fromPercentEncoding()是要走的路,OP在UPDATE部分做了什么应该是标题中问题的接受答案.
“Returns a human-displayable string representation of the URL. The output can be customized by passing flags with options. The option
RemovePassword is always enabled, since passwords should never be
shown back to users.”
实际上它没有声称任何解码能力,这里的文件不清楚它的行为.但至少密码部分是真的.我在Gitorious:找到了一些线索
“Add QUrl::toDisplayString(), which is toString() without password. And fix documentation of toString() which said this was the method to
use for displaying to humans, while this has never been true.”
测试代码
为了辨别不同功能的解码能力.以下代码已在Qt 5.2.1上测试过(尚未在Qt 5.3上测试过!)
QString target(/*path*/);
QUrl url_path(target);
qDebug() << "[Original String]:" << target;
qDebug() << "--------------------------------------------------------------