Changing text encoding in Emacs
March 4, 2009
I’m posting this mostly so I’ll know where to look the next time I forget…
This is definitely the king of obscure Emacs key combinations. To change the encoding of an existing file, use C-x RET f <encoding> RET.
Tab-completion works for the encoding. “utf-8” is the one I use most often, but “unix” and “dos” are also useful.
To make Emacs open files in UTF-8 per default, use the following snippet in .emacs:
(setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8)