screen: Character Translation
16.8 Character Translation
==========================
'Screen' has a powerful mechanism to translate characters to arbitrary
strings depending on the current font and terminal type. Use this
feature if you want to work with a common standard character set (say
ISO8851-latin1) even on terminals that scatter the more unusual
characters over several national language font pages.
Syntax:
XC=<CHARSET-MAPPING>{,,<CHARSET-MAPPING>}
<CHARSET-MAPPING> := <DESIGNATOR><TEMPLATE>{,<MAPPING>}
<MAPPING> := <CHAR-TO-BE-MAPPED><TEMPLATE-ARG>
The things in braces may be repeated any number of times.
A <CHARSET-MAPPING> tells screen how to map characters in font
<DESIGNATOR> ('B': Ascii, 'A': UK, 'K': german, etc.) to strings.
Every <MAPPING> describes to what string a single character will be
translated. A template mechanism is used, as most of the time the codes
have a lot in common (for example strings to switch to and from another
charset). Each occurrence of '%' in <TEMPLATE> gets substituted with
the TEMPLATE-ARG specified together with the character. If your strings
are not similar at all, then use '%' as a template and place the full
string in <TEMPLATE-ARG>. A quoting mechanism was added to make it
possible to use a real '%'. The '\' character quotes the special
characters '\', '%', and ','.
Here is an example:
termcap hp700 'XC=B\E(K%\E(B,\304[,\326\\\\,\334]'
This tells 'screen', how to translate ISOlatin1 (charset 'B') upper
case umlaut characters on a 'hp700' terminal that has a German charset.
'\304' gets translated to '\E(K[\E(B' and so on. Note that this line
gets parsed *three* times before the internal lookup table is built,
therefore a lot of quoting is needed to create a single '\'.
Another extension was added to allow more emulation: If a mapping
translates the unquoted '%' char, it will be sent to the terminal
whenever screen switches to the corresponding <DESIGNATOR>. In this
special case the template is assumed to be just '%' because the charset
switch sequence and the character mappings normally haven't much in
common.
This example shows one use of the extension:
termcap xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334'
Here, a part of the German ('K') charset is emulated on an xterm. If
screen has to change to the 'K' charset, '\E(B' will be sent to the
terminal, i.e. the ASCII charset is used instead. The template is just
'%', so the mapping is straightforward: '[' to '\304', '\' to '\326',
and ']' to '\334'.