Un-escaping string
#4

Quote:
Originally Posted by Sascha
Посмотреть сообщение
what about checking for a slash and then replacing it?
like
Код:
new pos = strfind(string, "\\", true, 0);
strdel(string, pos, pos);
maybe use a loop that checks for the backslash more often incase there are more than 1 in the string...
(the \\ because a \" would cause a " not to be detected as a ":P.. so I guess \\ would work)
What if there is more than 1 backslash?

To OP: Try this, I've copied it out of my GM and it works fine.

pawn Код:
stock RemoveBackslashes(const string[])
{
    new ret[256];
    memcpy(ret, string, _, 1024, sizeof(ret));
    for (new i = 0, length = strlen(ret); i < length; i ++)
    {
        if (ret[i] == '\\')
        {
            strdel(ret, i, i + 1);
            continue;
        }
    }
    return ret;
}
Example:

pawn Код:
printf("%s", RemoveBackslashes(string));
Reply


Messages In This Thread
Un-escaping string - by kristo - 11.06.2013, 08:27
Re: Un-escaping string - by Sascha - 11.06.2013, 09:13
Re: Un-escaping string - by Vince - 11.06.2013, 10:34
Re: Un-escaping string - by Emmet_ - 11.06.2013, 10:37
Re: Un-escaping string - by Sascha - 11.06.2013, 11:02

Forum Jump:


Users browsing this thread: 1 Guest(s)