import re


def sanitize(s):
    """ Remove escape codes and non ASCII characters from output
    """
    ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
    s = ansi_escape.sub('', s)
    mpa = dict.fromkeys(range(32))
    return s.translate(mpa).strip().replace(' ', '')