def ustr(value, hint_encoding='utf-8', errors='strict'):
 ttype = type(value)
 if (ttype is unicode):
  return value
 if ((ttype is str) or issubclass(ttype, str)):
  try:
   return unicode(value, hint_encoding, errors=errors)
  except Exception:
   pass
  for ln in get_encodings(hint_encoding):
   try:
    return unicode(value, ln, errors=errors)
   except Exception:
    pass
 if isinstance(value, Exception):
  return exception_to_unicode(value)
 try:
  return unicode(value)
 except Exception:
  raise UnicodeError(('unable to convert %r' % (value,)))

def ustr ( value , hint_encoding = 'utf-8' , errors = 'strict' ) : ttype = type ( value ) if ( ttype is unicode ) : return value if ( ( ttype is str ) or issubclass ( ttype , str ) ) : try : return unicode ( value , hint_encoding , errors = errors ) except Exception : pass for ln in get_encodings ( hint_encoding ) : try : return unicode ( value , ln , errors = errors ) except Exception : pass if isinstance ( value , Exception ) : return exception_to_unicode ( value ) try : return unicode ( value ) except Exception : raise UnicodeError ( ( 'unable to convert %r' % ( value , ) ) )
this method is similar to the builtin unicode .