Author Topic: sefun strip_raw_ansi()  (Read 1463 times)

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
sefun strip_raw_ansi()
« on: November 12, 2011, 10:05:40 PM »
This is something I added to the strip_colors() sefun, to handle weirdoes who add raw ANSI sequences to their I3 traffic.

Code: [Select]
string strip_raw_ansi(string str) {
    mixed stuff;
    string ret = "";

    stuff = pcre_assoc( str, ({ "(\e[[][0-9]+m)", "(\e[[][0-9]+;[0-9]+m)" }), ({ 1, 2 }), 0);
    for(int i = 0; i < sizeof(stuff[0]); i++) {
        if(!stuff[1][i])
            ret += stuff[0][i];
    }
    return ret;
}