def safe_unicode(string):
if not isinstance(string, basestring):<EOL><INDENT>string = unicode(string)<EOL><DEDENT>if isinstance(string, unicode):<EOL><INDENT>string = string.encode('<STR_LIT:utf8>')<EOL><DEDENT>return string<EOL>
Safely transform any object into utf8 encoded bytes