import codecs


def _normalize_utf8(text):
    """
    Normalizes text by replacing all non-latin-1 characters.
    """

    text = codecs.encode(text, 'latin-1', 'replace')
    text = codecs.decode(text, 'latin-1', 'replace')
    return text