how to decode QUrlnfo.name()? - qt

I received the following QUrlInfo string from QFtp::listInfo(QUrlInfo) and the correct URL fragment is actually set to ©®§µ here in a test.
But QUrlInfo.name() returns a String containing ©®§µ. I realize I must encode it somehow, but how do I do that?

This should work:
QString::fromUtf8(info.name().toAscii());

Related

Wordpress encodes GET parameter

I need to pass base64 encoded string as a GET parameter, yes, I know that's a bad idea, but it is necessary. The problem is that I need it like so:
http://example.com/?data=c29tZXRoaW5nQA==
But it changed the URL to:
http://example.com/?data=c29tZXRoaW5nQA%3D%3D
Is there a way to do it? Adding this parameter via the query_vars filter fixed the URL, but then always returns the blog page not frontpage.
you can urldecode() your parameter, which will turn it back into the normal one, when you get it. –
So
$returnValue = urldecode('c29tZXRoaW5nQA%3D%3D');
Will return
$returnValue = "c29tZXRoaW5nQA==";
In short :
$theImage = urldecode($_GET['data']);
Should give you your disired string

Query String Returning Different Values to that of the actual in the url

http://localhost:1079/BattleSimulator.aspx?userID=Unregistered_User&Troops=1111%1111%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0!1111%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0&Research=10%10%10%10%10%10%0!10%10%10%10%10%10%0&Sanctuary=0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0!0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0&Inventory=False%False%False%False%False%False!False%False%False%False%False%False&other=5!0&RNG=0&Dragons=-1%-1%-1%-1!-1%-1%-1%-1&BattleArts=0%0%0!0%0%0&Kaizer=2310000%1510000%0%15867000%910000%875!5011000%2810000%3158%182972948%2810000%803
^ this is the original Query Passed onto server,
But this is parsed on a very different way on the server
Ex:
http://prntscr.com/3h90fs
http://prntscr.com/3h90o2
the string returned from
Extention.QueryString("Troops")
is "111111%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0!1111%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0"
Why is this happening ? is it a bug ?
There are many chars that are reserved and can't be used in querystring. % is one of those.
You have to Encode a string to be shure that it will be properly decoded to the same string in the server.
In C# this can be done this way:
HttpContext.Current.Server.UrlEncode(destinationURL);
Why is this happening ?
Because added any(some) spaces(White Character ) between your values.
is it a bug ?
Nope. It's not a bug .
Solution.
You need use Trim() or remove Empty values by using Replace(" ","") in your query string values before send query string
See this links
Get Query String value containing spaces
Passing in a querystring with a space?
http://blogfornet.com/tag/how-to-use-space-in-url-query-string/
Request.QueryString giving me space instead of + sign

Passing Empty string parameter in URL

I want to pass an empty string parameter in a url. I don't know how to do it.
I am passing these parameters in the url for a grid. In the database if I using Race=''. I get the respective records. I need to pass this in the url
test.aspx?race=""
The url would look like this:
text.aspx?race=
or
text.aspx?race=&otherParam=value&etc=otherValue
Then you would have code to handle race being empty:
if(string.IsNullOrEmpty(Request.QueryString["race"]))
// handle the empty race differently
You can pass an empty string in url like this
test.aspx?race=%02%03
%02 - start of text ASCII Character
%03 - end of text ASCII Character
In this page you can find other characters too.
Dim race As String
race = ""
Response.Redirect("page.aspx?race=" & race)
Is this what you want??

Request.Querystring removes characters from encrypted text

In my application I take a user's e-mail address, encrypt it, and URLEncode it, and pass it along into a QueryString.
email = Server.UrlEncode(aes.Encrypt(email));
The landing page does a Request.Querystring["email"], UrlDecodes it, and then decrypts it.
string email = Server.UrlDecode(Request.QueryString["eId"]);
string decemail = aes.Decrypt(email);
return decemail;
Very strange behavior was happening where a "+" character was being removed and therefore the decryption was failing.
I attempted to remove the UrlDecode, but that didn't solve the problem.
What solved the problem was doing this:
string email = Request.QueryString["eId"].ToString();
string decemail = aes.Decrypt(email);
return decemail;
Getting rid of UrlDecode, and calling a ToString() on the querystring.
Does anyone know why this would happen? Does Request.QueryString call urlDecode by default? I don't think it does.
Also, why would doing the .ToString() work in this instance?
Yep Correct. Request.QueryString actually returns string that has already been url decoded.
Sources:
http://www.codeproject.com/KB/custom-controls/antiauto.aspx?msg=1475521
http://www.kamath.com/codelibrary/cl006_url.asp

How to identify data is Encoded using Server.UrlEncode() Asp.net

Can we identify whether input data is Encoded using Server.UrlEncode() method or not?
I am looking for something like "Server.IsUrlEncoded"?
This way you check also if url is properly encoded:
string url = "...";
if(Server.UrlEncode(Server.UrlDecode(url)) == url)
{
// do stuff
}
why don't you just decode and encode it regardless then you make sure it's encoded?

Resources