Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs opening and saving encoding

Tags:

emacs

I have a Perl source file in utf-8 encoding, LF ending. It contains English and Chinese characters. The questions are:

1.When I open file, the encoding is windows-1251-unix. I have to run these commands:

Alt-x revert-buffer-with-coding-system
> Coding system for visited file (default nil):
utf-8-auto-unix
> Revert buffer from file file_name.pl?
y

How to automatically open it in utf-8-auto-unix?

2.When I edit the file and try to save it, Emacs gives me a question:

> Select coding system (default raw-text):
utf-8-auto-unix

How to automatically save the file in utf-8-auto-unix? And get rid of the question.

like image 232
user4035 Avatar asked Dec 24 '11 23:12

user4035


2 Answers

You could add this comment to the top of the file:

# -*- coding: utf-8 -*-
like image 123
rkb Avatar answered Oct 26 '22 03:10

rkb


Use describe-variable(C-h v) to examine the variable current-language-environment; follow the customize link and set it to "UTF-8".

like image 22
huaiyuan Avatar answered Oct 26 '22 03:10

huaiyuan