Previous Next Contents

3. Text mode setup

Generally, the text mode setup is the easiest way to show and input Cyrillic characters. There is one significant complication, however: the text mode fonts and keyboard layout manipulations depend on terminal driver implementation. Therefore, there is no portable way to achieve the goal across different systems.

Right now, I describe the way to deal with the Linux console driver. Thus, if you have another system, don't expect it to work for you. Instead, consult your terminal driver manual. Nevertheless, send me any information you find, so I'll be able to include it in further versions of this document.

3.1 Linux Console

The Linux console driver is quite a flexible piece of software. It is capable of changing fonts as well as keyboard layouts. To achieve it, you'll need the kbd package. Both RedHat and Slackware install kbd as part of a system.

The kbd package contains keyboard control utilities as well as a big collection of fonts and keyboard layouts.

Cyrillic setup with kbd usually involves two things:

  1. Screen font setup. This is performed by the setfont program. The fonts files are located in /usr/lib/kbd/consolefonts. NOTE: Never run the setfont program under X because it will hang your system. This is because it works with low-level video card calls which X doesn't like.
  2. Load the appropriate keyboard layout with the loadkeys program.

NOTE: In RedHat 3.0.3, /usr/bin/loadkeys has too restrictive access permissions, namely 700 (rwx------). There are no reasons for that, since everyone may compile his own copy and execute it (the appropriate system calls are not root-only). Thus, just ask your sysadmin to set more reasonable permissions for it (for example, 755).

The following is an excerpt from my cyrload script, which sets up the Cyrillic mode for Linux console:

if [ notset.$DISPLAY != notset. ]; then
    echo "`basename $0`:  cannot run under X"
    exit
fi

loadkeys /usr/lib/kbd/keytables/ru.map
setfont /usr/lib/kbd/consolefonts/Cyr_a8x16
mapscrn /usr/lib/kbd/consoletrans/koi2alt
echo -ne "\033(K"              # the magic sequence
echo "Use the right Ctrl key to switch the mode..."

Let me explain it a bit. You load the appropriate keyboard mapping. Then you load a font corresponding to the Alt codeset. Then, in order to be able to display text in KOI8-R correctly, you load a screen translation table. What it does is a translation of some characters from the upper half of the codeset to the Alt encoding. The word 'some' is crucial here - not all characters get translated, therefore some of them, like IBM pseudographic characters get unmodified to the screen and display correctly, since they are compatible with the Alt codeset, as opposed to KOI8-R. To ensure this, run mc and pretend you are back to MS-DOS 3.3...

Finally, the magic sequence is important but I have no idea what on the Earth it does. I stole/borrowed/learned it from German HOWTO back in 1994, when it was like the only national language oriented HOWTO. If you have any idea about this magic sequence, please tell me.

Finally, for those purists, who don't wont to give the Alt codeset a chance, I'm attaching yet another version of the script above, using native KOI8-R fonts.

if [ notset.$DISPLAY != notset. ]; then
    echo "`basename $0`:  cannot run under X"
    exit
fi

loadkeys /usr/lib/kbd/keytables/ru.map
setfont /usr/lib/kbd/consolefonts/koi-8x16
echo "Use the right Ctrl key to switch the mode..."

However, don't expect nice borders in your text mode-based windowing applications.

Now you probably want to test it. Do the appropriate bash or tcsh setup, rerun it, then press the right Control key and make sure you are getting the cyrillic characters right. The 'q' key must produce russian "short i" character, 'w' generates "ts", etc.

If you've screwed something up, the very best thing to do is to reset to the original (that is, US) settings. Execute the following commands:

loadkeys /usr/lib/kbd/keytables/defkeymap.map
setfont /usr/lib/kbd/consolefonts/default8x16

NOTE: unfortunately enough, the console driver is not able to preserve it's state (at least easily enough), while running the X Window System. Therefore, after you leave the X (or switch from it to a console), you have to reload the console russian font.

3.2 FreeBSD Console

I am not using FreeBSD so I couldn't test the following information. All data in this section should be treated as just pointers to begin with. The FreeBSD project homepage may have some information on the subject. Another good source is the relcom.fido.ru.unix newsgroup. Also, check the resources listed in section resources.

Anyway, this is what Ilya K. Orehov suggests to do in order to make FreeBSD console speak Russian:

  1. In /etc/sysconfig add:
    
    keymap=ru.koi8-r
    keyrate=fast
    # NOTE: '^[' below is a single control character
    keychange="61 ^[[K"
    cursor=destructive
    scrnmap=koi8-r2cp866
    font8x16=cp866b-8x16
    font8x14=cp866-8x14
    font8x8=cp866-8x8
    
  2. In /etc/csh.login:
    setenv ENABLE_STARTUP_LOCALE
    setenv LANG ru_SU.KOI8-R
    setenv LESSCHARSET latin1
    
  3. Make analogous changes in /etc/profile


Previous Next Contents