DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Customizing device character mapping

Managing KBD module tables

KBD tables, which are used by the KBD STREAMS module and the iconv(1) command, are created and managed as follows:

Defining a KBD module table

The KBD table provides a means of defining mappings that can be compiled and downloaded into the KBD STREAMS module. The input file to kbdcomp(1M) has a defined syntax consisting of a series of map declarations. Within each map declaration are a number of definitions and functions.

A map declaration is of the form:

map(<name>) {
<expressions>
}

The <expressions> contained in the map declaration are one of the following forms:

define(<word> <value>)
<word>(<extension> <result>)

The definition statement, <define>, allows a mnemonic, <word> to be associated with <value>. It is useful for replacing character sequences with mnemonics to make the file more readable.

The assignment statement, <word>, results in <value> and <extension> being a valid combination. When this combination is encountered on input, it is mapped to <result>.

For a complete description of the syntax of this file see kbdcomp(1M).

For example, consider the file, German.map. shown in ``German.map KBD map''.

#
#  Sample mapping for a-umlaut, o-umlaut and u-umlaut
#
map(German) {
    define(umlaut,  '\042')
    umlaut(a  '')
    umlaut(o  '')
    umlaut(u  '')
    umlaut(' '  '"')
}

German.map KBD map

In this example we have defined the double quote character (octal 42) as a dead key. Whenever this key is followed by an a, o or u, this key will produce an a-umlaut, , o-umlaut, , or u-umlaut, respectively. Entering a double quote followed by a space will produce a double quote (") on the output.

``PC 437 to ISO 8859-1 KBD map'' shows part of the code set mapping table for PC 437 to ISO 8859-1 using the default mapping type.

   map full (437.88591.d) {
       string(\200 \307)
       string(\201 \374)
       string(\202 \351)
       string(\203 \342)
   

string(\300 '_') string(\301 '_') string(\302 '_') string(\303 '_') }

PC 437 to ISO 8859-1 KBD map

In this example we have declared a map called 437.88591.d. The full keyword means that the table will be indexed, rather than being linearly searched, when looking for a match. This makes the mapping more efficient. The string keyword is used to define a mapping of an input string to an output string. In this case, all strings are one character long, for example, C cedilla which is octal 201 in the PC 437 code set is mapped to octal 307, which is the code in ISO 8859-1. Characters that have no equivalent in ISO 8859-1, such as graphics characters, are mapped to an underscore, in this example the characters 300, 301, 302 and 303 octal.

Compiling the KBD module table

The example shown in ``German.map KBD map'' is compiled by entering:

kbdcomp -o German German.map

For more information see kbdcomp(1M).

Making the KBD module table available to the iconv command

If the table that has been created is to be used by the iconv command, an entry must be placed in the /usr/lib/iconv/iconv_data file. Each entry in this file consists of a line with five fields. The first two fields are the names of the code sets being mapped to and from respectively. These abbreviations are used for the -f and -t arguments when using iconv. The third and fourth fields are the names of the map and the file to use for this mapping; these names are normally the same. The fifth field is the mapping type, that is, d for default, b for best fit, and so on.

For example, the default mapping type entry in iconv_data for mapping PC 437 to ISO 8859-1 characters is shown in ``iconv_data entry for PC 437 to ISO 8859-1 mapping''.

   PC437    88591    437.88591.d    437.88591.d    d

iconv_data entry for PC 437 to ISO 8859-1 mapping

Making the KBD module publicly available

If you wish to make the table available to all users for attaching to the KBD module, it must be loaded as a public table.


NOTE: 1. You must be logged in as the super-user to do this.
2. The file asc.88591.d must be in the directory /usr/lib/kbd.

This can be achieved by entering:

kbdload -p 437.88591.d

Alternatively, by editing the /etc/rc2 and /etc/rc3 files, the table can be made publicly available when the machine is booted. To do this, add the following lines to the end of these files:

   strchg -h kbd
   /usr/lbin/kbdload -p /usr/lib/kbd/asc.88591.d

Unloading KBD tables


NOTE: Only the super-user may unload publicly loaded tables.

To unload a KBD table use the kbdload command with the -u flag. Make sure that, before doing this, there are no users who have this table attached.

For example, to unload the 88591.cpz map:

kbdload -u 88591.cpz


Next topic: Font maps
Previous topic: Example compose key map

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004