9

I want to change my default encoding system from non defined to UTF-8 (I think that would be useful). Now I have seen many different UTF-8 coding systems:

mule-utf-8        mule-utf-8-dos
mule-utf-8-mac    mule-utf-8-unix
prefer-utf-8      prefer-utf-8-dos
prefer-utf-8-mac  prefer-utf-8-unix
utf-8             utf-8-auto
utf-8-auto-dos    utf-8-auto-mac
utf-8-auto-unix   utf-8-dos
utf-8-emacs       utf-8-emacs-dos
utf-8-emacs-mac   utf-8-emacs-unix
utf-8-hfs         utf-8-hfs-dos
utf-8-hfs-mac     utf-8-hfs-unix
utf-8-mac         utf-8-unix
utf-8-with-signature     utf-8-with-signature-dos
utf-8-with-signature-mac utf-8-with-signature-unix

I am using a Mac and I am further confused about these different hfs and mac coding systems.

At the moment I decided to use utf-8 as follow based on this answer:

(setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
(set-language-environment 'utf-8)
;; (set-keyboard-coding-system 'utf-8-mac) ; For old Carbon emacs on OS X only
(setq locale-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(unless (eq system-type 'windows-nt)
  (set-selection-coding-system 'utf-8))
(prefer-coding-system 'utf-8)

But I would like to understand some more what I am doing and why another utf-8 would be better as a default coding system?

Rainer
  • 897
  • 10
  • 16
  • 2
    [This answer](http://stackoverflow.com/a/17864979/605276) provides good background on different utf-8 variants. – Juancho Jun 30 '15 at 14:01
  • I don't see `utf-8-hfs` and friends on my emacs, but there is `utf-8-nfd` instead. That is the encoding used by OS X to encode filenames. NFD is for Normalized Form Canonical Decomposition. NFC is more commonly used (C is for Composition). One difference is that a letter like å is encoded as a single code point in NFC, but two in NFD (the letter a followed by a composing character for the ring above). You should probably forget about these encodings; just hope that filenames are automagically encoded correctly anyhow. – Harald Hanche-Olsen Jul 01 '15 at 11:01
  • @Juancho Thanks - so I assume that, that I am OK when I use the utf-8 as a general setting. Thanks. – Rainer Jul 01 '15 at 12:19
  • @HaraldHanche-Olsen OK - As I am only using ASCII for file names, I should be OK then. Thanks. – Rainer Jul 01 '15 at 12:19
  • Yes, I try stick to ASCII for filenames myself, as I live in a multi-OS world and rely on all sorts of synchronization tools that I don't trust to deal with anything else. But it is annoying not to be able to use `blåbærsyltetøy` as part of a filename. 8-) – Harald Hanche-Olsen Jul 01 '15 at 14:15
  • 2
    AFAIK, utf-8 is the coding system used under macos for most things, and Emacs should already pick its coding systems accordingly for you. IOW, I think you should need *no configuration at all*. Please clarify why you "want to change my default encoding system". Maybe you're simply hitting an Emacs bug. – Stefan Nov 27 '17 at 16:20
  • Back when Macs used MacOS (which was before they used OSX which was before they used MacOS; yay naming), the end-of-line syntax on Macs was a single carriage return. That's what the `-mac` suffix'd coding system variants are for (ever since those days). Nowadays, since Macs started using OSX and subsequently MacOS (yay naming) the EOL syntax is (I believe) a single line feed, which is the `-unix` suffix/variant. I imagine the "will pick the correct variant" advice is sound, though. – phils Jul 30 '23 at 12:15

1 Answers1

0

Emacs has [Menu]->[Options]->[Multilingual Environment]->[Describe Coding System...] or C-h C to explain the difference and disambiguate the different coding systems.

p_wiersig
  • 1,051
  • 9
  • 15