Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which coding system should I use in Emacs?

I have just tried to save a simple *.rtf file with some websites and tips on how to use emacs and I got

These default coding systems were tried to encode text in the buffer `notes.rtf': (iso-latin-1-dos (315 . 8216) (338 . 8217) (1514 . 8220) (1525 . 8221)) However, each of them encountered characters it couldn't encode: iso-latin-1-dos cannot encode these: ‘ ’ “ ”
....
etc, etc, etc

Now what is that? Now it is asking me to chose an encoding system

Select coding system (default chinese-iso-8bit):

I don't even know what an encoding system is, and I would rather not have to choose one every time I try and save a document... Is there any way I can set an encoding system that will work with all my files so I don't have to worry about this?

I saw another question and asnswer elsewhere in this website (see it here) and it seems that if I type the following

(defun set-coding-system () (setq buffer-file-coding-system 'utf-8-unix)) (add-hook 'find-file-hook 'set-coding-system)

then I can have Emacs do this, but I am not sure... Can someone confirm this to me?

like image 891
Vivi Avatar asked May 25 '10 02:05

Vivi


1 Answers

Here's a pretty comprehensive group of magic invocations to make Emacs use UTF-8 everywhere by default:

  (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)   (set-selection-coding-system     (if (eq system-type 'windows-nt)         'utf-16-le  ;; https://rufflewind.com/2014-07-20/pasting-unicode-in-emacs-on-windows       'utf-8))   (prefer-coding-system 'utf-8) 
like image 193
sanityinc Avatar answered Oct 09 '22 00:10

sanityinc