W3cubDocs

/Elisp

Disabling Multibyte Characters

By default, Emacs starts in multibyte mode: it stores the contents of buffers and strings using an internal encoding that represents non-ASCII characters using multi-byte sequences. Multibyte mode allows you to use all the supported languages and scripts without limitations.

Under very special circumstances, you may want to disable multibyte character support, for a specific buffer. When multibyte characters are disabled in a buffer, we call that unibyte mode. In unibyte mode, each character in the buffer has a character code ranging from 0 through 255 (0377 octal); 0 through 127 (0177 octal) represent ASCII characters, and 128 (0200 octal) through 255 (0377 octal) represent non-ASCII characters.

To edit a particular file in unibyte representation, visit it using find-file-literally. See Visiting Functions. You can convert a multibyte buffer to unibyte by saving it to a file, killing the buffer, and visiting the file again with find-file-literally. Alternatively, you can use C-x RET c (universal-coding-system-argument) and specify ‘raw-text’ as the coding system with which to visit or save a file. See Specifying a Coding System for File Text in GNU Emacs Manual. Unlike find-file-literally, finding a file as ‘raw-text’ doesn’t disable format conversion, uncompression, or auto mode selection.

The buffer-local variable enable-multibyte-characters is non-nil in multibyte buffers, and nil in unibyte ones. The mode line also indicates whether a buffer is multibyte or not. With a graphical display, in a multibyte buffer, the portion of the mode line that indicates the character set has a tooltip that (amongst other things) says that the buffer is multibyte. In a unibyte buffer, the character set indicator is absent. Thus, in a unibyte buffer (when using a graphical display) there is normally nothing before the indication of the visited file’s end-of-line convention (colon, backslash, etc.), unless you are using an input method.

You can turn off multibyte support in a specific buffer by invoking the command toggle-enable-multibyte-characters in that buffer.

Copyright © 1990-1996, 1998-2019 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Disabling-Multibyte.html