[Qt-interest] Problem using URL with special characters
Scott Aron Bloom
Scott.Bloom at onshorecs.com
Mon Aug 29 16:21:40 CEST 2011
1) By turning on this flag, QUrl( QString ) will not get called when you
call QUrl( "http://......" )
Thus preventing #2
2) Do not call the Qurl constructor directly with a string
3) it should have been QUrl::fromEncoded which would create the proper
URL even when the text sent in includes % encoded characters... Ie your
URL.
So, instead of
QUrl url( "http://www.foo.bar/%234" );
Use
QUrl url = QUrl::fromEncoded("http://www.foo.bar/%234" )
Scott
-----Original Message-----
From: qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com
[mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On
Behalf Of kent williams
Sent: Monday, August 29, 2011 7:09 AM
To: Thiago Macieira; QT Interest List
Subject: Re: [Qt-interest] Problem using URL with special characters
some things in your reply (thanks BTW) confuse me.
1. #define QT_NO_URL_CAST_FROM_STRING is a compile-time flag. Are you
suggesting that I recompile Qt with that flag, or does it somehow affect
the behavior in my code?
2. 'Never call the QUrl constructor. By definition I can't use QUrl
without calling a constructor. Are you saying to do this?
QUrl url;
url.setUrl( urlString );
3. 'use QUrl::formEncoded' -- I'm not sure what to do with this.
That's an option of QUrl::toEncoded, which returns a QByteArray, but
that isn't much use. QNetworkRequest::setUrl takes a QUrl, a QByteArray
isn't of any use to me.
The whole reason that the equals sign is encoded in the URL as %3D is
that the resulting string is meant to be passed into SQL, and therefore
shouldn't be interpreted by the web server as an = sign.
On Fri, Aug 26, 2011 at 5:38 PM, Thiago Macieira <thiago at kde.org> wrote:
> 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.
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list