def sdecode(string_):
 encodings = get_encodings()
 for encoding in encodings:
  try:
   decoded = salt.utils.to_unicode(string_, encoding)
   (u' ' + decoded)
   return decoded
  except UnicodeDecodeError:
   continue
 return string_

def sdecode ( string_ ) : encodings = get_encodings ( ) for encoding in encodings : try : decoded = salt . utils . to_unicode ( string_ , encoding ) ( u' ' + decoded ) return decoded except UnicodeDecodeError : continue return string_
since we dont know where a string is coming from and that string will need to be safely decoded .