Emacs: File Encoding
What is Character Encoding
Set default encoding system for opening and saving, globally
How to declare a file with a specific encoding
List emacs file encoding systems
- Alt+x
list-coding-systems
-
Show a list of all coding systems.
How to open file with specific encoding
- Alt+x
revert-buffer-with-coding-system
-
Refresh current buffer using a specific coding system to decode the file.
Press Tab to list possible ones.
How to set a encoding system for saving current file
- Alt+x
set-buffer-file-coding-system
-
Set the file coding-system of the current buffer. (do a file save to save it with the new coding-system.)
Press Tab to see a list of possible values.
What is the encoding system used for current file
- buffer-file-coding-system
-
A Buffer Local Variable . Value is the character coding system for current buffer. 〔see Emacs: Show Variable Value〕
Set Encoding for Terminal output
This is important especially on Microsoft Windows. If you don't set this to utf-8, you may have problems with Python output of Unicode string.
Alt+x set-terminal-coding-system
put this in your Emacs Init File:
(set-terminal-coding-system 'utf-8-unix)
Set Encoding for Keyboard Input
Alt+x set-keyboard-coding-system
put this in your Emacs Init File:
(set-keyboard-coding-system 'utf-8-unix)
View Current Coding System Config
Alt+xdescribe-current-coding-system
View Emacs Doc of a Specific Coding System
Alt+x describe-coding-system
Reference
Emacs and Unicode
- Emacs: Insert Unicode Character
- Emacs: Insert Emoji
- Emacs: Input Method
- Emacs: Get Character Info, Cursor Position
- Emacs Init: Update Unicode Data