def encode_text(text):
    if isinstance(text, six.text_type):
        return text.encode('utf-8')
    try:
        return text.decode('utf-8').encode('utf-8')
    except (__HOLE__, UnicodeEncodeError):
        return text.encode('ascii', 'replace')
dataset/ETHPy150Open pudo/archivekit/archivekit/util.py/encode_text