How to keep percent encoded spaces in an url?
-
Hi,
I'm facing an issue when I try to open a site using QDesktopServices::openUrl(). The url I have in QString contains a list of space separated values in the query part. I replaced them with the percent encoded value (%20) already, but when this string us passed to QUrl it automatically changes them back to spaces.
Why? How can I disable this unwanted behaviour?
I would expect if I pass a string with spaces it encodes them to percent encoded values and not this opposit.
Thanks and regards,
Laszlo -
I don't understand the problem here - what exactly does your external program need? I don't see any need to percent encode the space for an argument of a programm so why do you need it?
@Christian-Ehrlicher and All
Hi,
I got an error message that the query is incorret. So my first understanding was that it requires encoded spaces. I finally realised that ther was a typo. So it works now with not encoded spaces. The missleading error message directed me into completley wrong direction.
Sorry for eating up your time and thank you all for helping me.
I really appreciate it.
Thanks and regards,
Laszlo -
Hi,
I'm facing an issue when I try to open a site using QDesktopServices::openUrl(). The url I have in QString contains a list of space separated values in the query part. I replaced them with the percent encoded value (%20) already, but when this string us passed to QUrl it automatically changes them back to spaces.
Why? How can I disable this unwanted behaviour?
I would expect if I pass a string with spaces it encodes them to percent encoded values and not this opposit.
Thanks and regards,
Laszlo@Blaise70 Maybe you need to use QUrl::DecodedMode, see https://doc.qt.io/qt-6/qurl.html#ParsingMode-enum
-
Hi,
I'm facing an issue when I try to open a site using QDesktopServices::openUrl(). The url I have in QString contains a list of space separated values in the query part. I replaced them with the percent encoded value (%20) already, but when this string us passed to QUrl it automatically changes them back to spaces.
Why? How can I disable this unwanted behaviour?
I would expect if I pass a string with spaces it encodes them to percent encoded values and not this opposit.
Thanks and regards,
Laszlo -
@Blaise70 Maybe you need to use QUrl::DecodedMode, see https://doc.qt.io/qt-6/qurl.html#ParsingMode-enum
-
@Blaise70
I don't think you are supposed to care, space and %20 are the same character. But I see there is enum QUrl::ComponentFormattingOptionQUrl::EncodeSpaces
0x100000 Leave space characters in their encoded form ("%20"
).@JonB
Thanks for your kind answer.
Yes, I looked at it, but unfortunatelt all the functions accepting this type are returning QString. Like query which seems converting the query part of the url into a Qstring. setQuery seems OK except it uses the ParsingMode enum and even though TolarentMode should work according to the help, it seems not.
I'll keep trying,
Thanks and regards,
Laszlo -
@JonB
Thanks for your kind answer.
Yes, I looked at it, but unfortunatelt all the functions accepting this type are returning QString. Like query which seems converting the query part of the url into a Qstring. setQuery seems OK except it uses the ParsingMode enum and even though TolarentMode should work according to the help, it seems not.
I'll keep trying,
Thanks and regards,
LaszloI don't understand the problem here - what exactly does your external program need? I don't see any need to percent encode the space for an argument of a programm so why do you need it?
-
I don't understand the problem here - what exactly does your external program need? I don't see any need to percent encode the space for an argument of a programm so why do you need it?
@Christian-Ehrlicher and All
Hi,
I got an error message that the query is incorret. So my first understanding was that it requires encoded spaces. I finally realised that ther was a typo. So it works now with not encoded spaces. The missleading error message directed me into completley wrong direction.
Sorry for eating up your time and thank you all for helping me.
I really appreciate it.
Thanks and regards,
Laszlo -