code: def get_system_encoding():
      
      try:
          encoding = locale.getdefaultlocale()[1] or 'ascii'
          codecs.lookup(encoding)
      except Exception:
          encoding = 'ascii'
      return encoding
docs: 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.  See tickets #10335 and #5846