ttimt
31st March 2015, 05:10
QString q1 = QUrl::toPercentEncoding(username,"","~");
QUrlQuery params;
params.addQueryItem("id", q1);
QString temp1 = params.query();
//temp1 is just testing
When I debug, q1 value is properly encoded.
But for the params and temp1, some are not encoded?
Example:
1. Assigning username with value
"~`!@#$%^&*()_+-=;':"<>?,./"
2. Now q1 will be
"%7E%60%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%3B%27%3A%22%3C%3E%3F%2C.%2F"
Above 3 characters - _ and . is not encoded and its the correct thing, no problem here.
3. But temp1 shows
"id=~%60%21%40#%24%25%5E%26%2A%28%29_%2B-%3D%3B%27%3A%22%3C%3E%3F%2C.%2F"
Almost same as q1, but ~ and #is not encoded? Why is that
4. Value of params.query id from debugging
"~`%21%40#%24%25^&%2A%28%29_%2B-=%3B%27%3A"<>%3F%2C.%2F"
Many became not encoded, but not ALL. Cause as I know, without using to PercentEncoding, the @ character will not be encoded to %40
I want value of params.query id to be encoded like q1.
As you can see above, I insert q1 into params.addQuery.
But then through debugging the params.query id value and temp1 is different from q1, some characters are not encoded.
I don't use QUrl::FullyEncoded cause it does not actually encode URL reserve characters like @.Tried it
How can I fix this?
QUrlQuery params;
params.addQueryItem("id", q1);
QString temp1 = params.query();
//temp1 is just testing
When I debug, q1 value is properly encoded.
But for the params and temp1, some are not encoded?
Example:
1. Assigning username with value
"~`!@#$%^&*()_+-=;':"<>?,./"
2. Now q1 will be
"%7E%60%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%3B%27%3A%22%3C%3E%3F%2C.%2F"
Above 3 characters - _ and . is not encoded and its the correct thing, no problem here.
3. But temp1 shows
"id=~%60%21%40#%24%25%5E%26%2A%28%29_%2B-%3D%3B%27%3A%22%3C%3E%3F%2C.%2F"
Almost same as q1, but ~ and #is not encoded? Why is that
4. Value of params.query id from debugging
"~`%21%40#%24%25^&%2A%28%29_%2B-=%3B%27%3A"<>%3F%2C.%2F"
Many became not encoded, but not ALL. Cause as I know, without using to PercentEncoding, the @ character will not be encoded to %40
I want value of params.query id to be encoded like q1.
As you can see above, I insert q1 into params.addQuery.
But then through debugging the params.query id value and temp1 is different from q1, some characters are not encoded.
I don't use QUrl::FullyEncoded cause it does not actually encode URL reserve characters like @.Tried it
How can I fix this?