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[])
{
new len = strlen(string);
if( len <= 0 ) return 0;
new temp[512];
new hexstr[3] = { '0' , '0' , 0 };
new pos = 0;
new tpos = 0;
while( pos < len && tpos < sizeof(temp) )
{
if( string[pos] == '%' )
{
hexstr[0] = string[pos+1];
hexstr[1] = string[pos+2];
pos += 3;
temp[tpos] = HexToDec(hexstr);
tpos++;
continue;
}
temp[tpos] = string[pos];
pos++;
tpos++;
}
setc(string,len,0);
copy(string,len,temp);
return 1;
}
__________________