import string


def to_ascii(s,replace_with='?'):
    """
    Convert a string to ASCII

    Converts the supplied string to ASCII by replacing
    any non-ASCII characters with the specified
    character (defaults to '?').
    """
    try:
        return str(s)
    except UnicodeEncodeError:
        s1 = []
        for c in s:
            if c in string.printable:
                s1.append(c)
            else:
                s1.append(replace_with)
        return ''.join(s1)