Quote:
Originally Posted by arne1288
"/items?type=5&name=i+have+spaces"
As this thing seems to be aimed at developers making their own things, I assume you're developing your own stuff that uses this thing, which means you could (remember code attribution!) "copy" this one:
From Dynamic MOTD by @psychonic:
UrlEncodeString
PHP Code:
// Taken from Dynamic MOTD by psychonic - https://forums.alliedmods.net/showthread.php?t=147193
// loosely based off of PHP's urlencode
void UrlEncodeString(char[] output, int size, const char[] input)
{
int icnt = 0;
int ocnt = 0;
for(;;)
{
if (ocnt == size)
{
output[ocnt-1] = '\0';
return;
}
int c = input[icnt];
if (c == '\0')
{
output[ocnt] = '\0';
return;
}
// Use '+' instead of '%20'.
// Still follows spec and takes up less of our limited buffer.
if (c == ' ')
{
output[ocnt++] = '+';
}
else if ((c < '0' && c != '-' && c != '.') ||
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a' && c != '_') ||
(c > 'z' && c != '~'))
{
output[ocnt++] = '%';
Format(output[ocnt], size-strlen(output[ocnt]), "%x", c);
ocnt += 2;
}
else
{
output[ocnt++] = c;
}
icnt++;
}
}
|
Correct, making an API and a plugin to use it. Hmm yeah i guess this would solve most things. Would be maybe nice to bake it into the extension since its focused around making web calls