def get_system_encoding():
 try:
  encoding = (locale.getdefaultlocale()[1] or 'ascii')
  codecs.lookup(encoding)
 except Exception:
  encoding = 'ascii'
 return encoding

def get_system_encoding ( ) : try : encoding = ( locale . getdefaultlocale ( ) [ 1 ] or 'ascii' ) codecs . lookup ( encoding ) except Exception : encoding = 'ascii' return encoding
the encoding of the default system locale but falls back to the given fallback encoding if the encoding is unsupported by python or could not be determined .