import codecs # Python standard library codecs.encode("A strange character","utf-8") # this would give you the utf-8 encoded bytes