code: def locale_check():
      
  
      # no need to check on Windows or when this application is frozen
      if sys.platform.startswith("win") or hasattr(sys, "frozen"):
          return
  
      language = encoding = None
      try:
          language, encoding = locale.getlocale()
      except ValueError as e:
          log.error("Could not determine the current locale: {}".format(e))
      if not language and not encoding:
          try:
              log.warning("Could not find a default locale, switching to C.UTF-8...")
              locale.setlocale(locale.LC_ALL, ("C", "UTF-8"))
          except locale.Error as e:
              log.error("Could not switch to the C.UTF-8 locale: {}".format(e))
              raise SystemExit
      elif encoding != "UTF-8":
          log.warning("Your locale {}.{} encoding is not UTF-8, switching to the UTF-8 version...".format(language, encoding))
          try:
              locale.setlocale(locale.LC_ALL, (language, "UTF-8"))
          except locale.Error as e:
              log.error("Could not set an UTF-8 encoding for the {} locale: {}".format(language, e))
              raise SystemExit
      else:
          log.info("Current locale is {}.{}".format(language, encoding))
docs: Checks if this application runs with a correct locale (i.e. supports UTF-8 encoding) and attempt to fix
      if this is not the case.
  
      This is to prevent UnicodeEncodeError with unicode paths when using standard library I/O operation
      methods (e.g. os.stat() or os.path.*) which rely on the system or user locale.
  
      More information can be found there: http://seasonofcode.com/posts/unicode-i-o-and-locales-in-python.html
      or there: http://robjwells.com/post/61198832297/get-your-us-ascii-out-of-my-face