如何不要转义(编码)URL中的特殊字符
按规范,URL中的特殊字符需要被转义,包括(^)。QUrl忠实执行,所有的特殊字符都被强制转义(编码)了。
但是问题来了。
有个网站,其URL中包含有^,用IE等浏览器可正常访问,没被转义(编码)。用QWebKit就不行了,^被转义(编码)成了%5E,无法访问这个链接了。
怎么办?
有没有办法要求QUrl不要转义(编码)^这个字符?
space / double-quote / "<" / ">" / "" / "^" / "`" / "{" / "|" / "}"
Constant Value Description
QUrl::TolerantMode 0 QUrl will try to correct some common errors in URLs. This mode is useful for parsing URLs coming from sources not known to be strictly standards-conforming.
QUrl::StrictMode 1 Only valid URLs are accepted. This mode is useful for general URL validation.
QUrl::DecodedMode 2 QUrl will interpret the URL component in the fully-decoded form, where percent characters stand for themselves, not as the beginning of a percent-encoded sequence. This mode is only valid for the setters setting components of a URL; it is not permitted in the QUrl constructor, in fromEncoded() or in setUrl(). For more information on this mode, see the documentation for QUrl::FullyDecoded.