Emacs personal configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 line
927B

  1. (defun sanityinc/utf8-locale-p (v)
  2. "Return whether locale string V relates to a UTF-8 locale."
  3. (and v (string-match "UTF-8" v)))
  4. (defun locale-is-utf8-p ()
  5. "Return t iff the \"locale\" command or environment variables prefer UTF-8."
  6. (or (sanityinc/utf8-locale-p (and (executable-find "locale") (shell-command-to-string "locale")))
  7. (sanityinc/utf8-locale-p (getenv "LC_ALL"))
  8. (sanityinc/utf8-locale-p (getenv "LC_CTYPE"))
  9. (sanityinc/utf8-locale-p (getenv "LANG"))))
  10. (when (or window-system (locale-is-utf8-p))
  11. (setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
  12. (set-language-environment 'utf-8)
  13. (setq locale-coding-system 'utf-8)
  14. (set-default-coding-systems 'utf-8)
  15. (set-terminal-coding-system 'utf-8)
  16. (unless (eq system-type 'windows-nt)
  17. (set-selection-coding-system 'utf-8))
  18. (prefer-coding-system 'utf-8))
  19. (provide 'init-locales)