Next: Explicit Encoding, Previous: Default Coding Systems, Up: Coding Systems [Contents][Index]
You can specify the coding system for a specific operation by binding
the variables coding-system-for-read
and/or
coding-system-for-write
.
If this variable is non-nil
, it specifies the coding system to
use for reading a file, or for input from a synchronous subprocess.
It also applies to any asynchronous subprocess or network stream, but in
a different way: the value of coding-system-for-read
when you
start the subprocess or open the network stream specifies the input
decoding method for that subprocess or network stream. It remains in
use for that subprocess or network stream unless and until overridden.
The right way to use this variable is to bind it with let
for a
specific I/O operation. Its global value is normally nil
, and
you should not globally set it to any other value. Here is an example
of the right way to use the variable:
;; Read the file with no character code conversion.
(let ((coding-system-for-read 'no-conversion))
(insert-file-contents filename))
When its value is non-nil
, this variable takes precedence over
all other methods of specifying a coding system to use for input,
including file-coding-system-alist
,
process-coding-system-alist
and
network-coding-system-alist
.
This works much like coding-system-for-read
, except that it
applies to output rather than input. It affects writing to files,
as well as sending output to subprocesses and net connections.
When a single operation does both input and output, as do
call-process-region
and start-process
, both
coding-system-for-read
and coding-system-for-write
affect it.
When this variable is non-nil
, no end-of-line conversion is done,
no matter which coding system is specified. This applies to all the
Emacs I/O and subprocess primitives, and to the explicit encoding and
decoding functions (see Explicit Encoding).
Sometimes, you need to prefer several coding systems for some
operation, rather than fix a single one. Emacs lets you specify a
priority order for using coding systems. This ordering affects the
sorting of lists of coding systems returned by functions such as
find-coding-systems-region
(see Lisp and Coding Systems).
This function returns the list of coding systems in the order of their
current priorities. Optional argument highestp, if
non-nil
, means return only the highest priority coding system.
This function puts coding-systems at the beginning of the priority list for coding systems, thus making their priority higher than all the rest.
This macro execute body, like progn
does
(see progn), with coding-systems at the front of
the priority list for coding systems. coding-systems should be
a list of coding systems to prefer during execution of body.
Next: Explicit Encoding, Previous: Default Coding Systems, Up: Coding Systems [Contents][Index]