[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

33.10.2 Encoding and I/O

The principal purpose of coding systems is for use in reading and writing files. The function insert-file-contents uses a coding system for decoding the file data, and write-region uses one to encode the buffer contents.

You can specify the coding system to use either explicitly (see section 33.10.6 Specifying a Coding System for One Operation), or implicitly using the defaulting mechanism (see section 33.10.5 Default Coding Systems). But these methods may not completely specify what to do. For example, they may choose a coding system such as undefined which leaves the character code conversion to be determined from the data. In these cases, the I/O operation finishes the job of choosing a coding system. Very often you will want to find out afterwards which coding system was chosen.

Variable: buffer-file-coding-system
This variable records the coding system that was used for visiting the current buffer. It is used for saving the buffer, and for writing part of the buffer with write-region. When those operations ask the user to specify a different coding system, buffer-file-coding-system is updated to the coding system specified.

However, buffer-file-coding-system does not affect sending text to a subprocess.

Variable: save-buffer-coding-system
This variable specifies the coding system for saving the buffer (by overriding buffer-file-coding-system). Note that it is not used for write-region.

When a command to save the buffer starts out to use buffer-file-coding-system (or save-buffer-coding-system), and that coding system cannot handle the actual text in the buffer, the command asks the user to choose another coding system. After that happens, the command also updates buffer-file-coding-system to represent the coding system that the user specified.

Variable: last-coding-system-used
I/O operations for files and subprocesses set this variable to the coding system name that was used. The explicit encoding and decoding functions (see section 33.10.7 Explicit Encoding and Decoding) set it too.

Warning: Since receiving subprocess output sets this variable, it can change whenever Emacs waits; therefore, you should copy the value shortly after the function call that stores the value you are interested in.

The variable selection-coding-system specifies how to encode selections for the window system. See section 29.18 Window System Selections.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 2, 2002 using texi2html