Decode URI encoded string
This is used to decode a URI encoded string like you often see in
web browsers e.g. http://someplace.com/some%20file.txt I needed this for a project and didn't know of any function that could do it. You'll need the HexToDec function found here: http://forums.alliedmods.net/showthread.php?t=46216 Code:
public decodeURI(string[]) |
Re: Decode URI encoded string
Ok when posting a tutorial include more information. Such as:
|
Re: Decode URI encoded string
Link wasn't intended to be a valid link. I placed "e.g." next to it which stands
for Example Given. A URI encoded string is usually used by the HTTP protocol to use special characters which are not permitted by the protocol. Say we have the space character which in hexadecimal is represented by 20 and is 32 in decimal ASCII however a HTTP request looks like this: GET /some file.txt HTTP/1.1 as we can see the server needs to parse this message and obviously we cannot use a space because it would screw up the parsing since the server will be using a space as the delimiter so in order to access a filename with a space on the server we would encode the URI to look like this: GET /some%20file.txt HTTP/1.1 Now the server can correctly parse the request without any problems however now it needs to decode the URI encoded string, in order to do this the server examines the string until it finds a '%' character meaning that we've reached an encoded character so the server grabs the next two characters and converts the given hexadecimal number, which in this example is 20, and converts it to an ASCII character which is 32. This function would take a string that looks like: %48ello%2DWorld%21 and convert it to its unencoded form: Hello-World! Unfortunately I have not written an encoding function yet but hopefully you get the idea. But overall URI encoded strings are usually used to make what would be over-complicated parsing into a simple one. |
Re: Decode URI encoded string
I was hoping you would put that in your original tuturial but oh well :). About the link thing, you'll see that I edited my post because I saw .txt at the end assumed it was some file with examples or something, but I realized what it was and quickly fixed my mistake ^^.
Anyways good job :up:. I will defiantly use this in a plugin I'm making. |
Re: Decode URI encoded string
Quote:
|
All times are GMT -4. The time now is 15:16. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.