strip_colours.c

skylib_fluffos_v3/mudlib/secure/simul_efun/strip_colours.c · 648 B

From the archive skylib_fluffos_v3.zip

Download the archive   « Back to the archive contents

/**
 * Contains some simul_efuns.
 * @author Pinkfish
 */

nosave mapping term_cache;

#define TERM_HANDLER "/handlers/term"

/**
 * This method strips the colour codes out of the resultant string.
 * This is used to send strings to systems outside the mud (like
 * the web and stuff).
 * @param str the string to strip
 * @return the stripped string
 */
string strip_colours( string str ) {
    if( !mapp(term_cache) ) {
        if( catch( term_cache = TERM_HANDLER->set_term_type("dumb") ) )
            term_cache = ([ ]);
    }
  
    if( str != "%^")
        return terminal_colour( str, term_cache );

    return "";

} /* strip_colours() */

Site Stats

Snippets: 1791
Codebases: 571