This is something I ended up needing for a plugin that sends command results through a socket to a bot, to get rid of color codes from chat messages formatted by morecolors or similar.
Not the most efficient but it works.
PHP Code:
stock void RemoveColorCodes(char[] szText, int iSize)
{
for (int i = 0; i < iSize && szText[i] != '\0'; i++)
{
if (szText[i] >= '\1' && szText[i] <= '\6')
{
strcopy(szText[i], iSize-i, szText[i+1]);
}
else
{
switch (szText[i])
{
case '\7':
{
strcopy(szText[i], iSize-i, szText[i+4]); // \x07%06X \x07 0x3E FF 3E (4 bytes)
}
case '\8':
{
strcopy(szText[i], iSize-i, szText[i+5]); // \x08 00 00 00 32 (5 bytes)
}
}
}
}
}
__________________