def _getTerminalCharset():
 try:
  charset = locale.getpreferredencoding()
  if charset:
   return charset
 except (locale.Error, AttributeError):
  pass
 try:
  charset = locale.nl_langinfo(locale.CODESET)
  if charset:
   return charset
 except (locale.Error, AttributeError):
  pass
 if (hasattr(sys.stdout, 'encoding') and sys.stdout.encoding):
  return sys.stdout.encoding
 return 'ASCII'

def _getTerminalCharset ( ) : try : charset = locale . getpreferredencoding ( ) if charset : return charset except ( locale . Error , AttributeError ) : pass try : charset = locale . nl_langinfo ( locale . CODESET ) if charset : return charset except ( locale . Error , AttributeError ) : pass if ( hasattr ( sys . stdout , 'encoding' ) and sys . stdout . encoding ) : return sys . stdout . encoding return 'ASCII'
function used by getterminalcharset() to get terminal charset .