Seems to work fine ... but there could be bugs inside.
PHP Code:
url_safe(unsafe_string[], safe_string[])
{
new unsafe[] =
{
0x24, 0x26, 0x2b, 0x2c, 0x2f, 0x3a, 0x3b, 0x3d, 0x3f, 0x40,
0x20, 0x22, 0x3c, 0x23, 0x25, 0x7b, 0x7c, 0x7d, 0x5c, 0x5e, 0x7e, 0x5b, 0x5d, 0x60
}
new safe[][4] =
{
"%24", "%26", "%2b", "%2c", "%2f", "%3a", "%3b", "%3d", "%3f", "%40",
"%20", "%22", "%3c", "%23", "%25", "%7b", "%7c", "%7d", "%5c", "%5e", "%7e", "%5b", "%5d", "%60"
}
new
length = strlen(unsafe_string),
max_length = length * 3
for (new i = 0; i < length; i++)
{
new bool:safe_char = true
for (new j = 0; j < 24; j++)
{
if (unsafe_string[i] == unsafe[j])
{
format(safe_string, max_length, "%s%s", safe_string, safe[j])
safe_char = false
break;
}
}
if (safe_char) format(safe_string, max_length, "%s%c", safe_string, unsafe_string[i])
}
}