def _clean_str(value, strip_whitespace=True):
    """
    Remove null values and whitespace, return a str

    This fn is used in two places: in SACTrace.read, to sanitize strings for
    SACTrace, and in sac_to_obspy_header, to sanitize strings for making a
    Trace that the user may have manually added.
    """
    null_term = value.find('\x00')
    if null_term >= 0:
        value = value[:null_term] + " " * len(value[null_term:])

    if strip_whitespace:
        value = value.strip()

    return value