PDA

View Full Version : Is this a bug in QUrl toEncoded function?



grayfox
11th June 2011, 16:28
QString str = "svn://myrepo/Templates/Visual Studio/ItemTemplates/Visual C#/";
QUrl url(str);
QString result = url.toEncoded();

The resulting value is:
"svn://myrepo/Templates/Visual%20Studio/ItemTemplates/Visual%20C#/"

// where '#' should really be encoded as '%23'

mvuori
12th June 2011, 10:48
It would be a bug if that method claimed to percent-encode all reserved characters defined in RFC 3986. But it doesn't. It promises only do this:

"The user info, path and fragment are all converted to UTF-8, and all non-ASCII characters are then percent encoded. The host name is encoded using Punycode."

MarekR22
13th June 2011, 11:03
use QUrl::toPercentEncoding (http://doc.qt.nokia.com/latest/qurl.html#toPercentEncoding) to resolve the problem. use include parameter to enforce encoding of character you think have to be encoded.

wysota
13th June 2011, 23:04
'#' is a perfectly good character in URLs.