def decode_as_string(text, encoding=None):
 if (encoding is None):
  encoding = _console_encoding
 if (not isinstance(text, unicode)):
  text = text.decode(encoding)
 text = unicodedata.normalize('NFC', text)
 return text

def decode_as_string ( text , encoding = None ) : if ( encoding is None ) : encoding = _console_encoding if ( not isinstance ( text , unicode ) ) : text = text . decode ( encoding ) text = unicodedata . normalize ( 'NFC' , text ) return text
decode the console or file output explicitly using getpreferredencoding .