Emacs: Declare File Encoding

By Xah Lee. Date: .

You can declare a file to be a specific encoding. [see Unicode Basics: Character Set, Encoding, UTF-8, Codepoint]

put this in the first line of the file:

-*- 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.

;; -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

(info "(emacs) File Variables")

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; -*-

Emacs and Unicode

File Encoding

Emacs Line Ending


Emacs Tutorial

Quick Start

Font

Split Window

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc