Convert a List of Strings to UTF-8 in Python
2009
If you'd like to learn more about programming, contact me for a one-on-one lesson.
def utf8ify(list):
'''Encode a list of strings in utf8'''
return [item.encode('utf8') for item in list]
This 2009 code reflects Python 2's string handling challenges—the distinction between byte strings and Unicode strings that was eliminated in Python 3's unified string model. Modern Python developers rarely need such explicit encoding functions.