Go to the first, previous, next, last section, table of contents.

Text Files and Binary Files

Emacs on MS-DOS distinguishes between text and binary files. This distinction is not part of MS-DOS; it is made by Emacs only. Emacs treats files of human-readable text (including program source code) as text files, and treats executable programs, compressed archives, etc., as binary files. Emacs uses the file name to decide whether to treat a file as text or binary: the variable file-name-buffer-file-type-alist defines the file name patterns which denote binary files.

Emacs reads and writes binary files verbatim. Text files use a two character sequence to end a line: carriage-return (control-m) followed by newline (control-j). When you visit a text file, Emacs strips off these control-m characters; when you write a text file to disk, Emacs puts them back in. Thus, the text appears within Emacs with just a newline character at the end of each line.

You can tell whether Emacs considers the visited file as text or binary based on the mode line (see section The Mode Line). Text files have a `T:' marker prefixed to the major mode name; binary files have a `B:' prefix.

One consequence of this special format-conversion of text files is that character positions as reported by Emacs (see section Cursor Position Information) do not agree with the file size information known to the operating system.


Go to the first, previous, next, last section, table of contents.