22.12 Coding Systems for Terminal I/O
C-x RET t coding RET
Use coding system coding for terminal output
( set-terminal-coding-system
).
C-x RET k coding RET
Use coding system coding for keyboard input
( set-keyboard-coding-system
).
The command C-x RET t
( set-terminal-coding-system
)
specifies the coding system for terminal output. If you specify a
character code for terminal output, all characters output to the
terminal are translated into that coding system.
This feature is useful for certain character-only terminals built to support specific languages or character sets—for example, European terminals that support one of the ISO Latin character sets. You need to specify the terminal coding system when using multibyte text, so that Emacs knows which characters the terminal can actually handle.
By default, output to the terminal is not translated at all, unless Emacs can deduce the proper coding system from your terminal type or your locale specification (see Language Environments).
The command C-x RET k
( set-keyboard-coding-system
),
or the variable keyboard-coding-system
, specifies the coding
system for keyboard input. Character-code translation of keyboard
input is useful for terminals with keys that send non-ASCII
graphic characters—for example, some terminals designed for ISO
Latin-1 or subsets of it.
By default, keyboard input is translated based on your system locale
setting. If your terminal does not really support the encoding
implied by your locale (for example, if you find it inserts a
non-ASCII character if you type M-i
), you will need to set
keyboard-coding-system
to nil
to turn off encoding.
You can do this by putting
(set-keyboard-coding-system nil)
in your init file.
Setting keyboard-coding-system
has no effect on MS-Windows,
except on old Windows 9X systems, in which case the encoding must
match the current codepage of the MS-Windows console, which can be
changed by calling w32-set-console-codepage
.
There is a similarity between using a coding system translation for keyboard input, and using an input method: both define sequences of keyboard input that translate into single characters. However, input methods are designed to be convenient for interactive use by humans, and the sequences that are translated are typically sequences of ASCII printing characters. Coding systems typically translate sequences of non-graphic characters.