Emacs: is there a way to determine the file encoding system?

Suppose I open a file and find there

Ïåñíÿ àëüïèíèñòîâ 

etc. Can I get emacs to find the correct encoding? For example, AkelPad has such a function - in most cases it will open a file with the correct encoding.

+6
source share
2 answers

This page http://www.gnu.org/s/libtool/manual/emacs/Recognize-Coding.html explains the emacs system for detecting encoding systems. You can control this to some extent:

The variables auto-encoding-alist, auto-coding-regexp-alist, and auto-coding functions are the strongest way to specify system coding for specific file name patterns or for files containing specific patterns

You may have accidentally disabled this feature:

However, there may be times when you want to read the escape sequences into a file as is. In this case, you can set the inhibit-iso-escape-detection variable to non-nil. Code detection then ignores any escape sequences and never uses ISO-2022 encoding. the result is that all escape sequences become visible in the buffer.

+4
source

Consider this: characters are really just numbers. You can open the text file and say, "I think this is ANSI." And then when you come across a number that you know is not in ANSI, the only thing you can say for sure is "normal, it's not ANSI."

You cannot automatically detect the encoding, but you may find that the encodings are probably incorrect. This way you can hypothesize coding, but you will never be completely sure.

+3
source

Source: https://habr.com/ru/post/897530/


All Articles