def safe_unicode(string):
if not PY3:<EOL><INDENT>uni = string.replace(u'<STR_LIT>', "<STR_LIT:'>")<EOL>return uni.encode('<STR_LIT:utf-8>')<EOL><DEDENT>return string<EOL>
If Python 2, replace non-ascii characters and return encoded string.