Emacs: Declare Encoding for One File (Unicode, UTF-8)
Declare Encoding in a File
You can declare a file to be a specific encoding.
put this in the first line of the file:
-*- coding: utf-8 -*-
;; -*- coding: utf-8 -*-
The line can start with a comment character of your language, such as
#
,
//
This magic line is also adopted by Ruby, Python.
First Line in Emacs Lisp Package
in emacs lisp packages, the first line is also used for declaring the package. but you can add the encoding line after it.
;;; xah-fly-keys.el --- ergonomic modal keybinding minor mode. -*- coding: utf-8; lexical-binding: t; -*-
Reference
Emacs and Unicode
- Emacs: Insert Unicode Character
- Emacs: Insert Emoji
- Emacs: Input Method
- Emacs: Get Char Info. Name, Position, Font, Encoding, Syntax, Etc
- Emacs Init: Update Unicode Data
File Encoding
- Emacs: File Encoding (Unicode, UTF-8)
- Emacs Init: Set Default File Encoding (Unicode, UTF-8)
- Emacs: Declare Encoding for One File (Unicode, UTF-8)