[Qt-interest] Problem using URL with special characters
Thiago Macieira
thiago at kde.org
Sat Aug 27 00:38:08 CEST 2011
On Friday, 26 de August de 2011 16:07:26 kent williams wrote:
> 'https://predict-hd.net/xnat/REST/projects/FMRI_HD_024/subjects/0252/experim
> ents/45602/scans/2?xnat:mrScanData/parameters/addParam[name%3DReviewed]/addf
> ield=Yes'
> So I'm guessing the problem is that that the QUrl encoding is garbling
> my URL. If I call toEncoded() I get this:
>
> https://predict-hd.net/xnat/REST/projects/FMRI_HD_024/subjects/0252/experime
> nts/45602/scans/2?xnat:mrScanData/parameters/addParam%5Bname%253DReviewed%5D
> /addfield=Yes
>
> In particular it's replacing my square brackets, and garbling the %3D
> (encoded '=')
>
> I'm new to using Qt in this way and I'm baffled as to how to get to
> NOT screw up my URL. Any ideas?
Note that the encoding of the brackets as %5B and %5D is perfectly correct.
Focus on what's wrong: your original URL had %3D and the encoded form you
produced says %253D.
My guess is that you made the same mistake that everyone does: due to a flaw in
QUrl's design, it's constructor is unusable. Please add this to your code:
#define QT_NO_URL_CAST_FROM_STRING
And make sure you never call the QUrl constructor.
You want to use QUrl::formEncoded.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110827/2d053d53/attachment.bin
More information about the Qt-interest-old
mailing list