import string


def strip_illegal_chars(text: str) -> str:
    """Remove illegal characters.

    This routine mimics the same behavior in ODK Briefcase when it
    names the resultant dataset file (the .csv output).

    Args:
        text: Input string

    Returns:
        A string with illegal characters removed.
    """
    whitespace_dict = {ord(i): ' ' for i in string.whitespace}
    punctuation_dict = {ord(i): '_' for i in string.punctuation}
    result = text.translate({**whitespace_dict, **punctuation_dict})
    return result