def remove_formatting_codes(line, irc=False):
if irc:<EOL><INDENT>line = escape(line)<EOL><DEDENT>new_line = '<STR_LIT>'<EOL>while len(line) > <NUM_LIT:0>:<EOL><INDENT>try:<EOL><INDENT>if line[<NUM_LIT:0>] == '<STR_LIT:$>':<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>] == '<STR_LIT:$>':<EOL><INDENT>new_line += '<STR_LIT:$>'<EOL>line = line[<NUM_LIT:1>:]<EOL><DEDENT>elif line[<NUM_LIT:0>] == '<STR_LIT:c>':<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>].isdigit():<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>].isdigit():<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>] == '<STR_LIT:U+002C>':<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>].isdigit():<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>].isdigit():<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif line[<NUM_LIT:0>] == '<STR_LIT:U+002C>':<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>].isdigit():<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL>if line[<NUM_LIT:0>].isdigit():<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if line[<NUM_LIT:0>] == '<STR_LIT:[>':<EOL><INDENT>while line[<NUM_LIT:0>] != '<STR_LIT:]>':<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>elif line[<NUM_LIT:0>] == '<STR_LIT:{>':<EOL><INDENT>if line[:<NUM_LIT:3>] == '<STR_LIT>':<EOL><INDENT>new_line += '<STR_LIT:$>'<EOL>line = line[<NUM_LIT:3>:]<EOL>continue<EOL><DEDENT>while line[<NUM_LIT:0>] != '<STR_LIT:}>':<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new_line += line[<NUM_LIT:0>]<EOL>line = line[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>return new_line<EOL>
Remove girc control codes from the given line.