home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / HOWTOs / CYRILLIC < prev    next >
Text File  |  1999-11-04  |  76KB  |  2,245 lines

  1.   The Linux Cyrillic HOWTO
  2.   Alexander L. Belikoff, (abel@bfr.co.il), Berger Financial
  3.   Research Ltd.
  4.   v4.0, 23 January 1998
  5.  
  6.   This document describes how to set up your Linux box to typeset, view
  7.   and print the documents in the Russian language.
  8.   ______________________________________________________________________
  9.  
  10.   Table of Contents
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   1. Administrativia
  68.  
  69.      1.1 Introduction
  70.      1.2 Availability and feedback
  71.      1.3 Acknowledgments and copyrights
  72.  
  73.   2. Theoretical background
  74.  
  75.      2.1 Characters and codesets
  76.  
  77.   3. Preparing your environment
  78.  
  79.      3.1 Text mode setup
  80.         3.1.1 Linux Console
  81.         3.1.2 FreeBSD Console
  82.      3.2 The X Window System
  83.         3.2.1 The X fonts.
  84.         3.2.2 The input translation
  85.      3.3 First steps - Cyrillic in shells
  86.      3.4 bash
  87.      3.5 csh/tcsh
  88.      3.6 ksh
  89.      3.7 less
  90.      3.8 mc (The Midnight Commander)
  91.      3.9 rlogin
  92.      3.10 zsh
  93.  
  94.   4. Editing text
  95.  
  96.      4.1 Emacs and XEmacs
  97.      4.2 Using vi
  98.      4.3 Editing text with joe
  99.      4.4 Spell-checking Russian
  100.  
  101.   5. Using Cyrillic with mail and news
  102.  
  103.      5.1 Setting up Mail User Agents
  104.         5.1.1 Emacs-based mail readers
  105.         5.1.2 pine
  106.      5.2 Configuring your MTA
  107.         5.2.1 sendmail
  108.         5.2.2 Other MTAs
  109.  
  110.   6. Browsing the Cyrillic Web
  111.  
  112.      6.1 lynx
  113.      6.2 Netscape navigator
  114.         6.2.1 Basic setup
  115.         6.2.2 Cyrillic text in frames and input areas
  116.         6.2.3 Advanced setup
  117.  
  118.   7. Cyrillic wordprocessing
  119.  
  120.      7.1 TeX-based environments
  121.         7.1.1 Using the Washington Cyrillic
  122.         7.1.2 KOI-8 package for teTeX
  123.         7.1.3 Using the cmcyralt package for LaTeX
  124.         7.1.4 Using the CyrTUG package
  125.      7.2 The StarOffice suite
  126.  
  127.   8. Printing and PostScript
  128.  
  129.      8.1 Text to PostScript conversion
  130.         8.1.1 An a2ps converter
  131.         8.1.2 The GNU enscript
  132.      8.2 Text to TeX conversion
  133.   9. Cyrillic in PostScript
  134.  
  135.      9.1 Adding Cyrillic fonts to Ghostscript
  136.  
  137.   10. Print setup
  138.  
  139.      10.1 Pre-loading Cyrillic fonts into a non-PostScript printer
  140.      10.2 Printing with different fonts
  141.  
  142.   11. Localization and Internationalization
  143.  
  144.      11.1 Locale
  145.         11.1.1 How to use locale
  146.         11.1.2 Locale-aware programming
  147.      11.2 Internationalization
  148.  
  149.   12. Staying compatible
  150.  
  151.      12.1 MIME-based data compatibility
  152.      12.2 Explicit character set conversion
  153.      12.3 Cyrillic in the DOS emulator
  154.  
  155.   13. Bibliography
  156.  
  157.   14. Summary of the various useful resources
  158.  
  159.  
  160.  
  161.   ______________________________________________________________________
  162.  
  163.   1.  Administrativia
  164.  
  165.  
  166.  
  167.   1.1.  Introduction
  168.  
  169.  
  170.   This document covers the things you need to successfully work with
  171.   information containing cyrillic text (mostly Russian) under Linux.
  172.   Although this document assumes your using Linux as an operating
  173.   system, most of information presented is equally applicable to many
  174.   other Unix flavors. I shall try to keep the distinction as visible as
  175.   possible.
  176.  
  177.   There are a number of popular Linux distributions. As an example
  178.   system I describe the RedHat 4.1 Linux (Vanderbildt) - the one I am
  179.   personally using. Nevertheless, I shall try to highlight the
  180.   differences, if they exist, in other popular distributions, such as
  181.   Debian GNU/Linux and Slackware Linux.
  182.  
  183.   Since such setup directly modifies and extends the Operating System,
  184.   you should understand, what you are doing. Even though I tried to keep
  185.   things as easy as possible, having some experience with a given piece
  186.   of software is an advantage. I am not going to describe what the X
  187.   Window System is or how to typeset the documents with TeX and LaTeX,
  188.   or how to install printer in Linux. Those issues are covered in other
  189.   documents.
  190.  
  191.   For the same reason, in most cases I describe a system-wide setup, by
  192.   default requiring root privileges. Still, if there is a possibility
  193.   for user-level setup, I'll try to mention it.
  194.  
  195.   NOTE: The X Window System, TeX and other Linux components are complex
  196.   systems with a sofisticated configuration. If you do something wrong,
  197.   you can not only fail with Russian setup, but to break the component
  198.   as well, if not the entire system. This is not to scare you off, but
  199.   merely to make you understand the seriousness of the process and be
  200.   careful. Preliminary backup of the config files is highly recommended.
  201.   Having a guru around is also advantageous.
  202.  
  203.  
  204.  
  205.  
  206.   1.2.  Availability and feedback
  207.  
  208.  
  209.   This document is available at sunsite.unc.edu or tsx-11.mit.edu as a
  210.   part of the Linux Document Project. Also, it may be available at
  211.   various FTP sites containing Linux. Moreover, it may be included as a
  212.   part of Linux distribution.
  213.  
  214.   If you have any suggestions or corrections regarding this document,
  215.   please, don't hesitate to contact me as abel@bfr.co.il. Any new and
  216.   useful information about Cyrillic support in various Unices is highly
  217.   appreciated. Remember, it will help the others.
  218.  
  219.  
  220.  
  221.   1.3.  Acknowledgments and copyrights
  222.  
  223.  
  224.   Many people helped me (and not only me) with valuable information and
  225.   suggestions. Even more people contributed software to the public
  226.   community. I am sorry if I forgot to mention somebody.
  227.  
  228.   So, here they go:
  229.  
  230.  
  231.   o  Bas V. de Bakker
  232.  
  233.   o  David Daves
  234.  
  235.   o  Serge Vakulenko
  236.  
  237.   o  Sergei O. Naoumov
  238.  
  239.   o  Winfried Truemper
  240.  
  241.   o  Ilya K. Orehov
  242.  
  243.   o  Michael Van Canneyt
  244.  
  245.   o  Alex Bogdanov
  246.  
  247.   o  ...and the countless helpful people from the relcom.fido.ru.unix
  248.      and relcom.fido.ru.linux Usenet newsgroups.
  249.  
  250.   This document is Copyright (C) 1995,1997 by Alexander L. Belikoff. It
  251.   may be used and distributed under the usual Linux HOWTO terms
  252.   described below.
  253.  
  254.   The following is a Linux HOWTO copyright notice:
  255.  
  256.  
  257.        Unless otherwise stated, Linux HOWTO documents are copy-
  258.        righted by their respective authors. Linux HOWTO documents
  259.        may be reproduced and distributed in whole or in part, in
  260.        any medium physical or electronic, as long as this copyright
  261.        notice is retained on all copies. Commercial redistribution
  262.        is allowed and encouraged; however, the author would like to
  263.        be notified of any such distributions.
  264.  
  265.        All translations, derivative works, or aggregate works
  266.        incorporating any Linux HOWTO documents must be covered
  267.        under this copyright notice.  That is, you may not produce a
  268.        derivative work from a HOWTO and impose additional restric-
  269.        tions on its distribution. Exceptions to these rules may be
  270.        granted under certain conditions; please contact the Linux
  271.        HOWTO coordinator at the address given below.
  272.  
  273.  
  274.  
  275.        In short, we wish to promote dissemination of this informa-
  276.        tion through as many channels as possible. However, we do
  277.        wish to retain copyright on the HOWTO documents, and would
  278.        like to be notified of any plans to redistribute the HOWTOs.
  279.  
  280.  
  281.   If you have questions, please contact Tim Bynum, the Linux HOWTO
  282.   coordinator, at linux-howto@sunsite.unc.edu. You may finger this
  283.   address for phone number and additional contact information.
  284.  
  285.   Unix is a technology trademark of the X/Open Ltd.; MS-DOS, Windows,
  286.   Windows 95, and Windows NT are trademarks of the Microsoft Corp.; The
  287.   X Window System is a trademark of The X Consortium Inc. Other
  288.   trademarks belong to the appropriate holders.
  289.  
  290.  
  291.  
  292.   2.  Theoretical background
  293.  
  294.  
  295.  
  296.   2.1.  Characters and codesets
  297.  
  298.  
  299.   In order to understand and print characters of various languages, the
  300.   system and software should be able to distinguish them from other
  301.   characters. That is, each unique character must have a unique
  302.   representation inside the operating system, or the particular software
  303.   package. Such collection of all unique characters, that the system is
  304.   able to represent at once, is called a codeset.
  305.  
  306.   At the time of the most operating system's creation, nobody cared
  307.   about software being multilingual. Therefore, the most popular codeset
  308.   was (and actually is) an ASCII (American Standard Code for Information
  309.   Interchange).
  310.  
  311.   The standard ASCII (aka 7-bit ASCII) comprises 128 unique codes. Some
  312.   of them ASCII defines as real printable characters, and some are so-
  313.   called control characters, which had special meanings in the old
  314.   communication protocols. Each element of the set is identified by an
  315.   integer character code (0-127). The subset of printable characters
  316.   represents those found on the typewriter's keyboard with some minor
  317.   additions. Each character occupies 7 least significant bits of a byte,
  318.   whereas the most significant one was used for control purposes (say,
  319.   transmission control in old communication packages).
  320.  
  321.   The 7-bit ASCII concept was extended by 8-bit ASCII (aka extended
  322.   ASCII). In this codeset, the characters' codes' range is 0-255. The
  323.   lower half (0-127) is pure ASCII, whereas the upper one contains 127
  324.   more characters. Since this codeset is backward compatible with the
  325.   ASCII (character still occupies 8 bit, the codes correspond the old
  326.   ASCII), this codeset gained wide popularity.
  327.  
  328.   The 8-bit ASCII doesn't define the contents of the upper half of the
  329.   codeset. Therefore the ISO organization took the responsibility of
  330.   defining a family of standards known as ISO 8859-X family. It is a
  331.   collection of 8-bit codesets, where the lower half of each codeset
  332.   (characters with codes 0-127) matches the ASCII and the upper parts
  333.   define characters for various languages. For example, the following
  334.   codesets are defined:
  335.  
  336.  
  337.   o  8859-1 - Europe, Latin America (also known as Latin 1)
  338.  
  339.   o  8859-2 - Eastern Europe
  340.  
  341.   o  8859-5 - Cyrillic
  342.  
  343.   o  8859-8 - Hebrew
  344.  
  345.   In Latin 1, the upper half of the table defines various characters
  346.   which are not part of the English alphabet, but are present in various
  347.   european languages (german umlauts, french accentes etc).
  348.  
  349.   Another popular extended ASCII implementation is so-called IBM
  350.   codepage (named after some computer company, that developed this
  351.   codeset for it's infamous personal computers). This one contains
  352.   pseudo-graphic characters in the upper half.
  353.  
  354.   Software, that doesn't make any assumptions about the 8-th bit of the
  355.   ASCII data is called 8-bit clean. Some older programs, designed with
  356.   7-bit ASCII in mind are not 8-bit clean and may work incorrectly with
  357.   your extended ASCII data. Most of packages, however, are able to deal
  358.   with the extended ASCII by default, or require some very basic setup.
  359.   NOTE: before posting the question "I did all setup right, but I cannot
  360.   enter/view Cyrillic characters!", please consult the section ``'' for
  361.   the notes on the program, you are using.
  362.  
  363.   For information about making your software 8-bit clean, see section
  364.   ``''.
  365.  
  366.   Since on most systems character occupies 8 bits, there is no way to
  367.   extend ASCII more and more. The way to implement new symbols in ASCII-
  368.   based codesets is creation of other extended ASCII implementations.
  369.   This is the way, the Cyrillic ASCII set is implemented.
  370.  
  371.   We already mentioned ISO 8859-5 standard as the one defining the
  372.   Cyrillic codeset. But as it often happens to the standards, this one
  373.   was developed without taking into account the real practices in the
  374.   former USSR. Therefore, one thing that standard really achieved was
  375.   another degree of confusion. I wouldn't say that ISO 8859-5 is widely
  376.   used anywhere.
  377.  
  378.   Other standards for Cyrillic include the so-called Alt codeset and
  379.   Microsoft CP1251 codepage. The former one was developed by (who?) for
  380.   MS-DOS quite a while ago. Back then, there was not very buzz yet about
  381.   internetworking, so the intention was to make it as compatible as
  382.   possible with the IBM standard. Therefore the Alt codeset is
  383.   effectively the same IBM codepage, where all specific European
  384.   characters in the upper half were replaced with the Cyrillic ones,
  385.   leaving the pseudographic ones. Therefore, it didn't screw the text
  386.   windowing facilities and provided Cyrillic characters as well.  The
  387.   Alt standard is still alive and extremely popular in MS-DOS.
  388.  
  389.   Microsoft CP1251 codepage is just an attempt of Microsoft to come up
  390.   with the new standard for Cyrillic codeset in Windows. As far as I
  391.   know, it is not compatible with anything else (not very surprizing,
  392.   huh?)
  393.  
  394.   And finally there is KOI8-R. This one is also quite old, but it was
  395.   designed wisely and nowadays the design points of it look really
  396.   useful.
  397.   Again, it is compatible with ASCII, and the Cyrillic characters are
  398.   located in the upper half. But the main design point of KOI8-R is that
  399.   the Cyrillic characters' positions must correspond to the English
  400.   characters with the same phonetics. Namely, if we set the eighth bit
  401.   of the English character 'a', we'll get the Cyrillic 'a'.  This means
  402.   that, given the Cyrillic text written in KOI8-R, we can strip the
  403.   eighth bit of each character and we still get a readable text,
  404.   although written with English characters! This is very important now,
  405.   since there are many mailers on the Internet, that just strip the
  406.   eighth bit silently, being sure that every single soul on the face of
  407.   the Earth speaks English.
  408.  
  409.   Not surprisingly, KOI8-R quickly became a de-facto standard for
  410.   Cyrillic on the Internet. Andrew A. Chernov did a tremendous amount of
  411.   work to make a standard in this area. He is an author of RFC 1489
  412.   ("Registration of a Cyrillic Character Set").
  413.  
  414.   These two standards differ only in positions of the cyrillic
  415.   characters in the table (that is in cyrillic character codes).
  416.  
  417.   The principal difference is that the Alt codeset is used by MS-DOS
  418.   users only, whereas KOI8-R is used in Unix, as well as in MS-DOS
  419.   (though in the latter KOI8-R is much less popular). Since we are doing
  420.   the right thing (namely working in the Unix operating system), we
  421.   shall focuse mostly on KOI8-R.
  422.  
  423.   As for the ISO standard, it is more popular in Europe and the US as a
  424.   standard for Cyrillic. The leader in Russia is definitely KOI8-R.
  425.  
  426.   There are other standards, which are different from ASCII and much
  427.   more flexible. Unicode is most known. However, they are not
  428.   implemented as good as the basic ones in Unix in general and  Linux in
  429.   particular. Therefore, I am not describing them here.
  430.  
  431.  
  432.  
  433.   3.  Preparing your environment
  434.  
  435.  
  436.   Before we start customizing various parts of the system functionality,
  437.   we have to set up a couple basic things. Most of tools described below
  438.   assume that there are Cyrillic fonts available and a user is able to
  439.   input Cyrillic characters. To make it true we have to configure the
  440.   environment to provide both fonts and input facility for Cyrillic.
  441.  
  442.   There are effectively two interface models supported by Linux. One is
  443.   the text mode, and the other one is the graphic mode, provided by the
  444.   X Window System. Both require different setup, which will be described
  445.   below.
  446.  
  447.  
  448.  
  449.   3.1.  Text mode setup
  450.  
  451.  
  452.   Generally, the text mode setup is the easiest way to show and input
  453.   Cyrillic characters. There is one significant complication, however:
  454.   the text mode fonts and keyboard layout manipulations depend on
  455.   terminal driver implementation. Therefore, there is no portable way to
  456.   achieve the goal across different systems.
  457.  
  458.   Right now, I describe the way to deal with the Linux console driver.
  459.   Thus, if you have another system, don't expect it to work for you.
  460.   Instead, consult your terminal driver manual. Nevertheless, send me
  461.   any information you find, so I'll be able to include it in further
  462.   versions of this document.
  463.   3.1.1.  Linux Console
  464.  
  465.  
  466.   The Linux console driver is quite a flexible piece of software. It is
  467.   capable of changing fonts as well as keyboard layouts. To achieve it,
  468.   you'll need the kbd package. Both RedHat and Slackware install kbd as
  469.   part of a system.
  470.  
  471.   The kbd package contains keyboard control utilities as well as a big
  472.   collection of fonts and keyboard layouts.
  473.  
  474.   Cyrillic setup with kbd usually involves two things:
  475.  
  476.  
  477.   1. Screen font setup. This is performed by the setfont program. The
  478.      fonts files are located in /usr/lib/kbd/consolefonts.
  479.  
  480.      NOTE: Never run the setfont program under X because it will hang
  481.      your system. This is because it works with low-level video card
  482.      calls which X doesn't like.
  483.  
  484.   2. Load the appropriate keyboard layout with the loadkeys program.
  485.  
  486.   NOTE: In RedHat 3.0.3, /usr/bin/loadkeys has too restrictive access
  487.   permissions, namely 700 (rwx------). There are no reasons for that,
  488.   since everyone may compile his own copy and execute it (the
  489.   appropriate system calls are not root-only). Thus, just ask your
  490.   sysadmin to set more reasonable permissions for it (for example, 755).
  491.  
  492.   The following is an excerpt from my cyrload script, which sets up the
  493.   Cyrillic mode for Linux console:
  494.  
  495.  
  496.   if [ notset.$DISPLAY != notset. ]; then
  497.       echo "`basename $0`:  cannot run under X"
  498.       exit
  499.   fi
  500.  
  501.   loadkeys /usr/lib/kbd/keytables/ru.map
  502.   setfont /usr/lib/kbd/consolefonts/Cyr_a8x16
  503.   mapscrn /usr/lib/kbd/consoletrans/koi2alt
  504.   echo -ne "\033(K"              # the magic sequence
  505.   echo "Use the right Ctrl key to switch the mode..."
  506.  
  507.  
  508.  
  509.   Let me explain it a bit. You load the appropriate keyboard mapping.
  510.   Then you load a font corresponding to the Alt codeset. Then, in order
  511.   to be able to display text in KOI8-R correctly, you load a screen
  512.   translation table. What it does is a translation of some characters
  513.   from the upper half of the codeset to the Alt encoding. The word
  514.   'some' is crucial here - not all characters get translated, therefore
  515.   some of them, like IBM pseudographic characters get unmodified to the
  516.   screen and display correctly, since they are compatible with the Alt
  517.   codeset, as opposed to KOI8-R. To ensure this, run mc and pretend you
  518.   are back to MS-DOS 3.3...
  519.  
  520.   Finally, the magic sequence is important but I have no idea what on
  521.   the Earth it does. I stole/borrowed/learned it from German HOWTO back
  522.   in 1994, when it was like the only national language oriented HOWTO.
  523.   If you have any idea about this magic sequence, please tell me.
  524.  
  525.   Finally, for those purists, who don't wont to give the Alt codeset a
  526.   chance, I'm attaching yet another version of the script above, using
  527.   native KOI8-R fonts.
  528.  
  529.   if [ notset.$DISPLAY != notset. ]; then
  530.       echo "`basename $0`:  cannot run under X"
  531.       exit
  532.   fi
  533.  
  534.   loadkeys /usr/lib/kbd/keytables/ru.map
  535.   setfont /usr/lib/kbd/consolefonts/koi-8x16
  536.   echo "Use the right Ctrl key to switch the mode..."
  537.  
  538.  
  539.  
  540.   However, don't expect nice borders in your text mode-based windowing
  541.   applications.
  542.  
  543.   Now you probably want to test it. Do the appropriate bash or tcsh
  544.   setup, rerun it, then press the right Control key and make sure you
  545.   are getting the cyrillic characters right. The 'q' key must produce
  546.   russian "short i" character, 'w' generates "ts", etc.
  547.  
  548.   If you've screwed something up, the very best thing to do is to reset
  549.   to the original (that is, US) settings. Execute the following
  550.   commands:
  551.  
  552.  
  553.   loadkeys /usr/lib/kbd/keytables/defkeymap.map
  554.   setfont /usr/lib/kbd/consolefonts/default8x16
  555.  
  556.  
  557.  
  558.   NOTE: unfortunately enough, the console driver is not able to preserve
  559.   it's state (at least easily enough), while running the X Window
  560.   System. Therefore, after you leave the X (or switch from it to a
  561.   console), you have to reload the console russian font.
  562.  
  563.  
  564.  
  565.   3.1.2.  FreeBSD Console
  566.  
  567.  
  568.   I am not using FreeBSD so I couldn't test the following information.
  569.   All data in this section should be treated as just pointers to begin
  570.   with. The FreeBSD project homepage may have some information on the
  571.   subject. Another good source is the relcom.fido.ru.unix newsgroup.
  572.   Also, check the resources listed in section ``''.
  573.  
  574.   Anyway, this is what Ilya K. Orehov suggests to do in order to make
  575.   FreeBSD console speak Russian:
  576.  
  577.  
  578.   1. In /etc/sysconfig add:
  579.  
  580.  
  581.  
  582.      keymap=ru.koi8-r
  583.      keyrate=fast
  584.      # NOTE: '^[' below is a single control character
  585.      keychange="61 ^[[K"
  586.      cursor=destructive
  587.      scrnmap=koi8-r2cp866
  588.      font8x16=cp866b-8x16
  589.      font8x14=cp866-8x14
  590.      font8x8=cp866-8x8
  591.  
  592.  
  593.  
  594.  
  595.   2. In /etc/csh.login:
  596.  
  597.  
  598.      setenv ENABLE_STARTUP_LOCALE
  599.      setenv LANG ru_SU.KOI8-R
  600.      setenv LESSCHARSET latin1
  601.  
  602.  
  603.  
  604.   3. Make analogous changes in /etc/profile
  605.  
  606.  
  607.  
  608.   3.2.  The X Window System
  609.  
  610.  
  611.   Like the console mode, the X environment also requires some setup.
  612.   This involves setting up the input mode and the X fonts. Both are
  613.   being discussed below.
  614.  
  615.  
  616.  
  617.   3.2.1.  The X fonts.
  618.  
  619.  
  620.   First of all, you have to obtain the fonts having the Cyrillic glyphs
  621.   at the appropriate positions.
  622.  
  623.   If you are using the most recent X (or XFree86) distribution, chances
  624.   are, that you already have such fonts. In the late 1995, the X Window
  625.   System incorporated a set of Cyrillic fonts, created by Cronyx. Ask
  626.   your system administrator, or, if you are the one, check your system,
  627.   namely:
  628.  
  629.  
  630.   1. Run 'xlsfonts | grep koi8'. If there are fonts listed, your X
  631.      server is already aware about the fonts.
  632.  
  633.   2. Otherwise, run
  634.  
  635.  
  636.      find -name crox\*.pcf\*
  637.  
  638.  
  639.  
  640.   to find the location of the Cyrillic fonts in the system. You'll have
  641.   to enable those fonts to the X server, as I explain below.
  642.  
  643.   If you haven't found such fonts installed, you'll have to do it
  644.   yourself.
  645.  
  646.   There is some ambiguity with the fonts. XFree86 docs claim that the
  647.   russian fonts collection included in the distribution is developed by
  648.   Cronyx. Nevertheless, you may find another set of Cronyx Cyrillic
  649.   fonts on the net (eg. on ftp.kiae.su), known as the xrus package
  650.   (don't confuse it with the xrus program, which is used to setup a
  651.   Cyrillic keyboard layout. Hopefully, tha letter one was renamed to
  652.   xruskb recently). Xrus has fewer fonts than the collection in Xfree86
  653.   (38 vs 68), but the latter one didn't go along with my ``Netscape''
  654.   setup - it gave me some really huge font in the menubar. The xrus
  655.   package doesn't have this problem.
  656.  
  657.   I would suggest you to download and try both of them. Pick up the one
  658.   which you'll like more. Also, I'm going to creat RPM packages soon for
  659.   both collections and download them to ftp.redhat.com.
  660.  
  661.   There are also older stuff, for example the vakufonts package, created
  662.   by Serge Vakulenko, which was the base for the one in the X
  663.   distribution. There are also a number of others. The important point
  664.   is that the fonts' names in the old collection were not strictly
  665.   conforming to the standard. The latter is fine in general, but
  666.   sometimes it may cause various weird errors. For example, I had a bad
  667.   experience with Maple V for Linux, which crashed mysteriously with the
  668.   vakufonts package, but ran smoothly with the "standard" ones.
  669.  
  670.   So, let's start with the fonts:
  671.  
  672.  
  673.   1. Download the appropriate fonts collection. The package for XFree86
  674.      may be found at any FTP site, containing the X distribution, for
  675.      example, directly from the XFree86 FTP site. The xrus package may
  676.      be found on ftp.kiae.su
  677.  
  678.   2. Now when you have the fonts, you create some directory for them. It
  679.      is generally a bad idea to put new fonts to the already existing
  680.      font directory. So, place them, to, say,
  681.      /usr/lib/X11/fonts/cyrillic for a system-wide setup, or just create
  682.      a private directory for personal use.
  683.  
  684.   3. If the new fonts are in BDF format (*.bdf files), you have to
  685.      compile them. For each font do:
  686.  
  687.  
  688.      bdftopcf -o <font>.pcf <font>.bdf
  689.  
  690.  
  691.  
  692.   If your server supports compressed fonts, do it, using the compress
  693.   program:
  694.  
  695.  
  696.   compress *.pcf
  697.  
  698.  
  699.  
  700.   Also, if you do want to put the new fonts to an already existing font
  701.   directory. you have to concatenate the old and the new files named
  702.   fonts.alias in the case both of them exist.
  703.  
  704.   4. Each font directory in the X must contain a list of fonts in it.
  705.      This list is stored in the file fonts.dir. You don't have to create
  706.      this list manually. Instead, do:
  707.  
  708.  
  709.      cd <new font directory>
  710.      mkfontdir .
  711.  
  712.  
  713.  
  714.   5. Now you have to make this font directory known to the X server.
  715.      Here, you have a number of options:
  716.  
  717.  
  718.   o  System-wide setup for XFree86. If you are running this version of
  719.      X, then append the new directory to the list of directories in the
  720.      file XF86Config. To find the location of this file, see output of
  721.      startx. Also, see XF86Config(4/5) for details.
  722.  
  723.   o  System-wide setup through xinit. Add the new directory to the xinit
  724.      startup file. See xinit(1x) and the next option for details.
  725.  
  726.  
  727.   o  Personal setup. You have a special start-up file for the X -
  728.      ~/.xinitrc (or ~/.Xclients, or ~/.xsession for the RedHat users).
  729.      Add the following commands to it:
  730.  
  731.  
  732.  
  733.      xset +fp <new font directory>
  734.      xset fp rehash
  735.  
  736.  
  737.  
  738.   It is important to note that '+fp' means that the new fonts will be
  739.   added to the head of the font path list. That is, if an application
  740.   requests say a fixed font, it'll be given the one with Cyrillic char-
  741.   acters, which is definitely what we are trying to achieve.
  742.  
  743.   There are problems, though. The fixed font in the cyrillic fonts dis-
  744.   tribution doesn't have it's bold and italic counterparts. My font of
  745.   choice is 6x13, so, since it also lacks bold and italic typefaces, I
  746.   cannot use Emacs/XEmacs faces in their full glory. Hopefully somebody
  747.   will ultimately create those fonts and the situation will change.
  748.  
  749.   6. Now restart your X. If you have done everything right, the tests in
  750.      the beginning of the section will be successful. Also, play with
  751.      xfontsel(1x) to make sure you are able to select the cyrillic
  752.      fonts.
  753.  
  754.   In order to make the X clients use the Cyrillic fonts, you have to set
  755.   up the appropriate X resources. For example, I make the russian font
  756.   the default one in my ~/.Xdefaults:
  757.  
  758.  
  759.   *font:         6x13
  760.  
  761.  
  762.  
  763.   Since my cyrillic fonts are first in the font path (see output of
  764.  
  765.   This just a simple case. If you want to set the appropriate part of
  766.   the X client to a cyrillic font, you have to figure out the name of
  767.   the resource (eg. using editres(1x)) and to specify it either in the
  768.   resource database, or in the command line. Here go some examples:
  769.  
  770.  
  771.   $ xterm -font '-cronyx-*-bold-*-*-*-19-*-*-*-*-*-*-*'
  772.  
  773.  
  774.  
  775.   ...will run xterm with some ugly font; and
  776.  
  777.  
  778.   $ xfontsel -xrm '*quitButton.font: -*-times-*-*-*-*-13-*-*-*-*-*-koi8-*'
  779.  
  780.  
  781.  
  782.   ...will set a Cyrillic Times font for the Quit button in xfontsel.
  783.  
  784.  
  785.  
  786.   3.2.2.  The input translation
  787.  
  788.  
  789.   In the newest X releases (X11R61 and higher) there are two "standard"
  790.   input methods: the original one, working through the xmodmap utility,
  791.   and the new one called Xkb (X KeyBoard). The very first thing you have
  792.   to do is to disable the Xkb method! Don't get charmed by it's ability
  793.   to set up a "russian keyboard". It looks like this method is using the
  794.   Cyrillic keysyms defined in keysymdef.h. This file defines keysyms for
  795.   many languages. The only problem is that those definitions have
  796.   nothing to do with the extended ASCII codeset - the one most programs
  797.   are only able to operate with! I hardly know any programs being able
  798.   to grok the keysymdef.h keysyms, different from 8-bit ASCII. However
  799.   our goal is to get the KOI8-R support to work.
  800.  
  801.   To disable the Xkb support, browse through the Keyboard section of
  802.   your XF86Config file and comment all lines starting with Xkb (case
  803.   doesn't matter). Instead, put the following line:
  804.  
  805.  
  806.   XkbDisable
  807.  
  808.  
  809.  
  810.   The xmodmap program.allows customization of codes emitted by various
  811.   characters and their combinations. It sets the things up based on the
  812.   file containing the translation table.
  813.  
  814.   In the previous versions of this document I used to describe the
  815.   xmodmap-based setup in a great detail. This proved to be almost
  816.   useless. The Xmodmap-based input translation method is well known as
  817.   being it is non-portable, inflexible, and incomplete.  Your
  818.   configuration may work with one XFree version and fail with a
  819.   different one. Even worse, sometimes things differ accross different
  820.   servers in the same distribution.
  821.  
  822.   I strongly suggest you not to play with this xmodmap, at least for
  823.   now. Apart from headache and disappointment you'll gain nothing.
  824.   Instead, I recommend installing the xruskb package, which allows you
  825.   to configure most of the input translation parameters without having
  826.   to know about xmodmap. Again, the RedHat Linux users are free to
  827.   download and install an RPM package.
  828.  
  829.  
  830.  
  831.   3.3.  First steps - Cyrillic in shells
  832.  
  833.  
  834.  
  835.   3.4.  bash
  836.  
  837.  
  838.   Three variables should be set on order to make bash understand the
  839.   8-bit characters. The best place is ~/.inputrc file. The following
  840.   should be set:
  841.  
  842.  
  843.   set meta-flag on
  844.   set convert-meta off
  845.   set output-meta on
  846.  
  847.  
  848.  
  849.  
  850.  
  851.   3.5.  csh/tcsh
  852.  
  853.  
  854.   The following should be set in .cshrc:
  855.  
  856.  
  857.  
  858.  
  859.   setenv LC_CTYPE iso_8859_5
  860.   stty pass8
  861.  
  862.  
  863.  
  864.   If you don't have the POSIX stty (impossible for Linux), then replace
  865.   the last call to the following:
  866.  
  867.  
  868.   stty -istrip cs8
  869.  
  870.  
  871.  
  872.  
  873.  
  874.   3.6.  ksh
  875.  
  876.  
  877.   As for the public domain ksh implementation - pdksh 5.1.3, you can
  878.   input 8 bit characters only in vi input mode. Use:
  879.  
  880.  
  881.   set -o vi
  882.  
  883.  
  884.  
  885.  
  886.  
  887.   3.7.  less
  888.  
  889.  
  890.   So far, less doesn't support the KOI8-R character set, but the
  891.   following environment variable will do the job:
  892.  
  893.  
  894.   LESSCHARSET=latin1
  895.  
  896.  
  897.  
  898.  
  899.  
  900.   3.8.  mc (The Midnight Commander)
  901.  
  902.  
  903.   To display Cyrillic text correctly, select the full 8 bits item in the
  904.   Options/Display menu.
  905.  
  906.   If your problem is the ugly windows' borders, consult the ``''
  907.   section.
  908.  
  909.   As an off-topic, if you want to make mc use color in an Xterm window,
  910.   set the variable COLORTERM:
  911.  
  912.  
  913.   COLORTERM= ; export COLORTERM
  914.  
  915.  
  916.  
  917.  
  918.  
  919.   3.9.  rlogin
  920.  
  921.  
  922.   Make sure that the shell on the destination site is properly set up.
  923.   Then, if your rlogin doesn't work by default, use 'rlogin -8'.
  924.  
  925.   3.10.  zsh
  926.  
  927.  
  928.   Use the same way as with csh (see section ``csh''). The startup files
  929.   in this case are .zshrc or /etc/zshrc.
  930.  
  931.  
  932.  
  933.   4.  Editing text
  934.  
  935.  
  936.   In this section I'll describe how to customize various text editors to
  937.   work with Cyrillic text. This doesn't cover the word processors, which
  938.   will be described later (see section ``'').
  939.  
  940.  
  941.  
  942.   4.1.  Emacs and XEmacs
  943.  
  944.  
  945.   There are two version of the Emacs editor - GNU Emacs and XEmacs.
  946.   While they provide more or less same functionality, some
  947.   implementation details are significantly different. Cyrillic setup
  948.   requires some low-level (in Emacs Lisp sense) tweaking, and it differs
  949.   a bit for those two versions.
  950.  
  951.   NOTE: Apart from the setup described here, there is an alternative way
  952.   to configure both versions of emacs - use MULE (MULtilanguage Emacs
  953.   support). The latter way is fairly complicated and (to the best of my
  954.   knowledge) rarely used, so I don't discuss it here.
  955.  
  956.   The minimal cyrillic support in GNU emacs (you don't have to do it for
  957.   the XEmacs) is done by adding the following calls to one's .emacs
  958.   (provided that the Cyrillic character set support is installed for
  959.   console or X respectively):
  960.  
  961.  
  962.   (standard-display-european t)
  963.  
  964.   (set-input-mode (car (current-input-mode))
  965.      (nth 1 (current-input-mode))
  966.      0)
  967.  
  968.  
  969.  
  970.   This allows the user to view and input documents in Russian.
  971.  
  972.   However, it isn't enough. Emacs doesn't know yet, that Cyrililic
  973.   characters may constitute a word, let alon the upper/lower case
  974.   conversion rules. In order to teach Emacs doing that, you have to
  975.   modify the syntax and case tables of emacs:
  976.  
  977.  
  978.   (require 'case-table)
  979.  
  980.   (let* ((ruc "\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361")
  981.          (rlc "\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321")
  982.          (i 0)
  983.          (len (length ruc)))
  984.     (while (< i len)
  985.       (modify-syntax-entry (elt ruc i) "w  ")
  986.       (modify-syntax-entry (elt rlc i) "w  ")
  987.       (set-case-syntax-pair (elt ruc i) (elt rlc i) (standard-case-table))
  988.       (setq i (+ i 1))))
  989.  
  990.  
  991.   For this purpose I created a rusup.el file which does this, as well as
  992.   a couple handy functions. You have to load it in your ~/.emacs.
  993.  
  994.   Finally, the russian.el <http://www.math.uga.edu/~valery/russian.el>
  995.   package by Valery Alexeev (valery@math.uga.edu) allows the user to
  996.   switch between cyrillic and regular input mode and to translate the
  997.   contents of a buffer from one Cyrillic coding standard to another
  998.   (which is especially useful while reading the texts imported from MS-
  999.   DOS or Windows).
  1000.  
  1001.  
  1002.  
  1003.   4.2.  Using vi
  1004.  
  1005.  
  1006.   The vi editor (at least it's clone vim, available in most Linux
  1007.   distributions) is aware of 8-bit characters. It will allow you to
  1008.   enter cyrillic characters and will be able to recognize the word
  1009.   boundaries correctly. I don't know about the upper-/lower-case
  1010.   conversion rules, since I don't use vi much. If you know something
  1011.   about it, please inform me.
  1012.  
  1013.  
  1014.  
  1015.   4.3.  Editing text with joe
  1016.  
  1017.  
  1018.   Joe requires a special -asis option to recognize 8-bit characters. You
  1019.   may either specify this option at the command line, or to put it in
  1020.   ~/.joerc file (for personal use, or in /usr/lib/joerc for system-wide
  1021.   setup.
  1022.  
  1023.   If your program doesn't understand -asis option, you have to upgrade
  1024.   to the newer version.
  1025.  
  1026.   However, joe doesn't seem to understand the cyrillic words' boundaries
  1027.   correctly. I assume, that it applies both to the case conversion
  1028.   rules.
  1029.  
  1030.  
  1031.  
  1032.   4.4.  Spell-checking Russian
  1033.  
  1034.  
  1035.   The program I use to spell-check text is the GNU ispell. It is very
  1036.   flexible and extensible, so it is possible to use it to spell-check
  1037.   text in languages, other than English, by adding new spell
  1038.   dictionaries.
  1039.  
  1040.   Constantine Knizhnik has created a very good Russian dictionary for
  1041.   ispell. You may find it at his homepage. The distribution includes a
  1042.   handy incremental spelling script for emacs.
  1043.  
  1044.   Ideally, if you already have an ispell properly installed, you have to
  1045.   just step into the newly-created directory and generate the
  1046.   dictionary, using the commands provided in the Makefile. However,
  1047.   chances are quite high, that you'll see a lot of complaints about the
  1048.   ispell's unawareness of the 8-bit data. This is because in most
  1049.   distributions, ispell is compiled without 8-bit data support. In this
  1050.   case, you cannot avoid recompiling the ispell package.
  1051.  
  1052.   Again, RedHat users will be delighted to know that I've rebuilt the
  1053.   ispell package with both Russian and German dictionaries. As usual,
  1054.   you may grab it from the RedHat FTP site.
  1055.  
  1056.  
  1057.   Once you have everything installed, you may invoke Russian spell-
  1058.   check, by supplying '-d russian' option to ispell.
  1059.  
  1060.   Now, if you use Emacs, you may want to add a menu item for a russian
  1061.   dictionary. I sent a proposed menu entry to the ispell.el maintainer
  1062.   and he kindly agreed to include it in the the next public release of
  1063.   the file. Meanwhile, you may do it by adding the following code in
  1064.   your ~/.emacs (or in /usr/share/emacs/site-lisp/site-start.el for a
  1065.   system-wide setup):
  1066.  
  1067.  
  1068.   (setq ispell-dictionary-alist
  1069.     (append ispell-dictionary-alist
  1070.             '(("russian"
  1071.                "[\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]"
  1072.                "[^\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]"
  1073.                "[']" t ("-C" "-d" "russian") "~latin1"))))
  1074.  
  1075.   (define-key-after ispell-menu-map [ispell-select-russian]
  1076.     '("Select Russian (KOI-8)" . (lambda ()
  1077.                                    (interactive)
  1078.                                    (ispell-change-dictionary "russian")))
  1079.     'british)
  1080.  
  1081.  
  1082.  
  1083.   Unfortunately, it won't work for the XEmacs. I'll try to solve this
  1084.   problem later.
  1085.  
  1086.  
  1087.  
  1088.   5.  Using Cyrillic with mail and news
  1089.  
  1090.  
  1091.   Setting up your mail and news software to recognize Cyrillic text is
  1092.   not very difficult, although you have to possess some knowledge of
  1093.   principles, mail and news work by.
  1094.  
  1095.   Internet electronic mail software generally consists of two parts: MUA
  1096.   (Mail User Agent) and MTA (Mail Transfer Agent). MUA is the program
  1097.   you use to read, compose, and send mail. However, MUA doesn't transfer
  1098.   mail messages by itself. Instead, it calls the MTA, which is
  1099.   reponsible to send message using an appropriate protocol to the
  1100.   appropriate direction. For example, your MUA may be Pine and MTA -
  1101.   qmail.
  1102.  
  1103.   Until quite recently, both MTA and MUA weren't 8-bit clean by default.
  1104.   Therefore, whenever you sent your message from say America to Russia,
  1105.   you were never sure, that some intermediate MTA won't strip the 8th
  1106.   bit from each character of your message. Therefore, a set of protocols
  1107.   was developed, which allowed encoding various kinds of data using only
  1108.   printable characters from 7-bit ASCII. This family of protocols is
  1109.   called MIME (MultimedIa Mail Encoding).
  1110.  
  1111.   Since MIME is usually pre-configured to reasonable defaults, we won't
  1112.   describe it here. We will talk more about MIME when we provide a
  1113.   backward compatibility with other Cyrillic encodings (section ``'').
  1114.  
  1115.   Meanwhile, we start MUA setup, because it is usually up to an end-
  1116.   user. Then, we will describe the basic priciples of the MTA
  1117.   configuration for Cyrillic.
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.   5.1.  Setting up Mail User Agents
  1124.  
  1125.  
  1126.  
  1127.  
  1128.   5.1.1.  Emacs-based mail readers
  1129.  
  1130.  
  1131.   Basically, you don't need any special setup for Emacs-based readers,
  1132.   geivedn, that you've already configured the emacs itself (see section
  1133.   ``'').
  1134.  
  1135.  
  1136.  
  1137.   5.1.2.  pine
  1138.  
  1139.  
  1140.   Set the following directive in ~/.pinerc for personal configuration,
  1141.   or in /usr/lib/pine.conf for a global one:
  1142.  
  1143.  
  1144.   character-set=ISO-8859-5
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.   5.2.  Configuring your MTA
  1151.  
  1152.  
  1153.   There are a number of MTAs available now. These include sendmail,
  1154.   qmail, smail, exim, and others.
  1155.  
  1156.  
  1157.  
  1158.   5.2.1.  sendmail
  1159.  
  1160.  
  1161.   So far, sendmail is much more popular than other MTAs, because it's
  1162.   long history and widespread use. Personally, I hate this program - it
  1163.   is a perfect example of a completely moronic design and even it's
  1164.   "improvements" with the passion of time show, that this approach is
  1165.   not going to cease. Any system administrator shudders, when he hears
  1166.   the ominous "sendmail.cf" name...
  1167.  
  1168.   As of now, sendmail doesn't strip the 8th bit anymore. However, it may
  1169.   encode the 8-bit data using a special base64 encoding. Although most
  1170.   MUAs are supposed to recognize it and decode it back to a regular
  1171.   data, you may want to start with sending raw 8-bit text to make sure
  1172.   everything works.
  1173.  
  1174.   As of version 8, sendmail handles 8-bit data correctly by default. If
  1175.   it doesn't do it for you, check the EightBitMode option and option 7
  1176.   given to mailers in your /etc/sendmail.cf. See "Sendmail. Operation
  1177.   and Installation Guide" for details.
  1178.  
  1179.  
  1180.  
  1181.   5.2.2.  Other MTAs
  1182.  
  1183.  
  1184.   I don't know much about other MTAs. If you know something, which may
  1185.   be important for Cyrillic setup, please inform me.
  1186.  
  1187.  
  1188.  
  1189.   6.  Browsing the Cyrillic Web
  1190.  
  1191.  
  1192.   Unlike e-mail and news, there is no definitive standard for Cyrillic
  1193.   encoding for the Web. This is primarily because Microsoft offers Web
  1194.   authoring tools, which only allow cp1251 codeset for Cyrillic,
  1195.   completely ignoring the fact that any other standards may already
  1196.   exist.
  1197.  
  1198.   The setup described here is very basic. It will allow you to view
  1199.   pages in the KOI8-R codeset. If the situation improves, I'll add more
  1200.   information.
  1201.  
  1202.  
  1203.  
  1204.   6.1.  lynx
  1205.  
  1206.  
  1207.   As of version 2.6, you may select the appropriate encoding for the
  1208.   display Character set option.
  1209.  
  1210.  
  1211.  
  1212.   6.2.  Netscape navigator
  1213.  
  1214.  
  1215.   Make sure you are using Netscape version higher than 3. If your
  1216.   Netscape is older, download a new one from www.netscape.com.
  1217.  
  1218.  
  1219.  
  1220.   6.2.1.  Basic setup
  1221.  
  1222.  
  1223.   To be able to see Cyrillic text in most parts of the HTML document, do
  1224.   the following:
  1225.  
  1226.  
  1227.   o  In menu Options/Document Encoding select Cyrillic(KOI-8).
  1228.  
  1229.   o  In menu Options/General Preferences/Fonts select Cyrillic (KOI-8)
  1230.      encoding, Times(Cronyx) as a proportional font and Courier(Cronyx)
  1231.      as a fixed one.
  1232.  
  1233.   o  save options.
  1234.  
  1235.   NOTE: This setup will work with most parts of the document. However,
  1236.   you won't be able to display Cyrillic text in the window header, menus
  1237.   and some controls. Attempts to fix it follows.
  1238.  
  1239.  
  1240.  
  1241.   6.2.2.  Cyrillic text in frames and input areas
  1242.  
  1243.  
  1244.   To fix this, it is usually enough to:
  1245.  
  1246.  
  1247.   1. Copy the Netscape properties database (usually Netscape.ad) to
  1248.      ~/Netscape.
  1249.  
  1250.   2. In the latter file, set the following property:
  1251.  
  1252.  
  1253.      *documentFonts.charset*iso8859-1:           koi8-r
  1254.  
  1255.   This will force all frame and input elements to use the fonts with
  1256.   koi8-r encoding instead of the default ones, therefore you have to
  1257.   make sure you have installed such fonts (see section ``'').
  1258.  
  1259.   The bad news about the trick above is that if you load a document
  1260.   which is supposed to be displayed in iso-8859-1 fonts, it will be
  1261.   displayed using the koi8 fonts instead. Sometimes such documents will
  1262.   look worse.
  1263.  
  1264.  
  1265.  
  1266.   6.2.3.  Advanced setup
  1267.  
  1268.  
  1269.   Andrew A. Chernov is the one, who knows more than others about KOI-8
  1270.   in general and netscape in particular. Visit his excellent KOI-8 page
  1271.   and download a patch for Netscape resource file, making Netscape speak
  1272.   Russian as much as it is able to.
  1273.  
  1274.  
  1275.  
  1276.   7.  Cyrillic wordprocessing
  1277.  
  1278.  
  1279.  
  1280.  
  1281.   7.1.  TeX-based environments
  1282.  
  1283.  
  1284.   In this section I'll describe several ways to make TeX and LaTeX
  1285.   typeset Cyrillic texts. There are several ways, which differ in setup
  1286.   sophistication and usage convenience. For example, one possibility is
  1287.   to start without any preliminary setup and use the Washington AMSTeX
  1288.   Cyrillic fonts. On the other hand, you may install a LaTeX package,
  1289.   providing a very high degree of Cyrillic setup. I have an experience
  1290.   with two such packages. One is the cmcyralt package by Vadim V.
  1291.   Zhytnikov (vvzhy@phy.ncu.edu.tw) and Alexander Harin
  1292.   (harin@lourie.und.ac.za), and the other one is the LH package by the
  1293.   CyrTUG group with styles and hyphenation for LaTeX2e by Sergei O.
  1294.   Naoumov (serge@astro.unc.edu). I'll describe both.
  1295.  
  1296.   Note, that there are two versions of LaTeX available - 2.09 is the old
  1297.   one, while 2e is a new pre-3.0 release. If you are using LaTeX 2.09,
  1298.   then switch quickly to the 2e. The latter retains compatibility with
  1299.   the old one, but has much more features. Hopefully, version 3 will be
  1300.   released soon. I describe a LaTeX 2e setup.
  1301.  
  1302.   Also, both of these packages require the Cyrillic text to be typeset
  1303.   using the Alt codeset, not KOI8-R! This is caused by historical
  1304.   reasons, since the creators of these packages used to work with EmTeX
  1305.   - the MS-DOG version of TeX (they didn't know about Linux yet :-).
  1306.   Switching to the KOI8-R requires some effort and is being expected to
  1307.   be done soon. So far, use some utility to convert your russian text
  1308.   from KOI8-R to Alt. See section ``''.
  1309.  
  1310.  
  1311.  
  1312.   7.1.1.  Using the Washington Cyrillic
  1313.  
  1314.  
  1315.   This package was created for the American Mathematic Society to
  1316.   provide documents with Russian references. Therefore, the authors were
  1317.   not very careful and the fonts look quite clumsy. This package is
  1318.   usually referred to as a "really bad cyrillic package for TeX".
  1319.  
  1320.  
  1321.   Nevertheless, we'll discuss it, because it is very easy to use and
  1322.   doesn't require any setup - this collection is supplied with most of
  1323.   TeX distributions.
  1324.  
  1325.   Of course, you won't be able to use such luxury as automatic
  1326.   hyphenation, but anyway...
  1327.  
  1328.   1. Prepend your document with the following directives:
  1329.  
  1330.  
  1331.   \input cyracc.def
  1332.   \font\tencyr=wncyr10
  1333.   \def\cyr{\tencyr\cyracc}
  1334.  
  1335.  
  1336.  
  1337.   2. Now to type a cyrillic letter, you enter
  1338.  
  1339.  
  1340.   \cyr
  1341.  
  1342.  
  1343.  
  1344.   and use a corresponding latin letter or a TeX command. Thus, the lower
  1345.   case of the Russian alphabet is expressed by the following codes:
  1346.  
  1347.  
  1348.   a b v g d e \"e zh z i {\u i} k l m n o p r s t u f kh c ch sh shch
  1349.   {\cprime} y {\cdprime} \`e yu ya
  1350.  
  1351.  
  1352.  
  1353.   It is extremely inconvenient to convert your Russian texts to such
  1354.   encoding, but you can automate the process. The translit program
  1355.   (section ``'') supports a TeX output option.
  1356.  
  1357.  
  1358.  
  1359.   7.1.2.  KOI-8 package for teTeX
  1360.  
  1361.  
  1362.   There is some new teTeX-rus package. It is reported to support KOI-8
  1363.   character set and have all basic stuff required for TeX and LaTeX. I
  1364.   personally haven't tried it yes, although I heard about it's
  1365.   successfull usage.
  1366.  
  1367.   NOTE: This package requires you to reconfigure and rebuild some parts
  1368.   of your teTeX package (for example the precompiled LaTeX macros).
  1369.   Unless you know what you are doing, you shouldn't try it without
  1370.   necessary care. Otherwise, you may be better off by borrowing the
  1371.   precompiled parts fron somebody on the net
  1372.  
  1373.  
  1374.  
  1375.   7.1.3.  Using the cmcyralt package for LaTeX
  1376.  
  1377.  
  1378.   The cmcyralt package can be found on any CTAN (Comprehensive TeX
  1379.   Archive Network) site like ftp.dante.de. You should obtain two pieces:
  1380.   the fonts collection from fonts/cmcyralt and the styles and
  1381.   hyphenation rules from macros/latex/contrib/others/cmcyralt.
  1382.  
  1383.   Note: Make sure you have the Sauter package installed, since cmcyralt
  1384.   requires some fonts from it. You can get this package from CTAN site
  1385.   as well.
  1386.  
  1387.   Now you should do the following:
  1388.  
  1389.  
  1390.   1. Put the new fonts to the TeX fonts tree. On my system (Slackware
  1391.      2.2) I created a cmcyralt directory in the
  1392.      /usr/lib/texmf/fonts/cm/. Create the src, tfm, and vf
  1393.      subdirectories in it. Put there .mf, .tfm, and vf files
  1394.      respectively.
  1395.  
  1396.   2. Put the font driver files (*.fd) from the styles archive to the
  1397.      appropriate place (in my case it was /usr/lib/texmf/tex/latex/fd).
  1398.  
  1399.   3. Put the style files (*.sty) to the appropriate LaTeX styles
  1400.      directory (in my case /usr/lib/texmf/tex/latex/sty).
  1401.  
  1402.   Now the hyphenation setup. This requires to remake the LaTeX base
  1403.   file.
  1404.  
  1405.  
  1406.   1. The file hyphen.cfg contains the directives for both English and
  1407.      Russian hyphenation. Extract the one for Russian and place it to
  1408.      the LaTeX hyphenation config file lthyphen.ltx. In my case, that
  1409.      file was in /usr/lib/texmf/tex/latex/latex-base.
  1410.  
  1411.   2. Put the rhyphen.tex to the same directory. It is needed for making
  1412.      the new base file. Later, you can remove it.
  1413.  
  1414.   3. Do 'make' in that directory. Don't for get to make a link from
  1415.      Makefile to Makefile.unx. During the make process check the output.
  1416.      There should be a message:
  1417.  
  1418.  
  1419.      Loading hyphenation patterns for Russian.
  1420.  
  1421.  
  1422.  
  1423.   If everything goes OK, you will get the new latex.fmt in that direc-
  1424.   tory. Put it to the appropriate place, where the previous one was
  1425.   (like /usr/lib/texmf/ini/). Don't forget to save the previous one!.
  1426.  
  1427.   This is it. The installation is complete. Try processing the examples
  1428.   found in the styles archive. If you are to create the PostScript files
  1429.   without any problems, then everything is OK. Now, to use Cyrillic in
  1430.   LaTeX, prepend your document with the following directive:
  1431.  
  1432.  
  1433.   \usepackage{cmcyralt}
  1434.  
  1435.  
  1436.  
  1437.   For more details, see the README file in the cmcyralt styles archive.
  1438.  
  1439.   Note: if you do have problems with the examples, provided you have
  1440.   installed the things right, then probably your TeX system hasn't been
  1441.   installed correctly. For example, during my first try, every attempt
  1442.   to create the .pk files for the russian fonts failed (MakeTeXPK
  1443.   stage). A substantial investigation discovered some implicit conflict
  1444.   between the localfont and ljfour METAFONT configurations. It used to
  1445.   work before, but kept crashing after the cmcyralt installation.
  1446.   Contact your local TeX guru - TeX is very (sometimes too much)
  1447.   complicated to reconfigure it without any prior knowledge.
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.   7.1.4.  Using the CyrTUG package
  1454.  
  1455.  
  1456.   You can obtain the CyrTUG package from the SunSite archive. Get the
  1457.   files CyrTUGfonts.tar.gz, CyrTUGmacro.tar.gz, and hyphen.tar.Z.
  1458.  
  1459.   The process of installation doesn't differ from too much the previous
  1460.   one.
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.   7.2.  The StarOffice suite
  1467.  
  1468.  
  1469.   Youri Kovalenko () has compiled a concise summary on StarOffice
  1470.   russification. It is located at .  I never had a chance to try it, so
  1471.   I cannot say anything about it's correctness.
  1472.  
  1473.   Another source of information on the subject is compiled by Eugene
  1474.   Demidov () and is located at .
  1475.  
  1476.  
  1477.  
  1478.   8.  Printing and PostScript
  1479.  
  1480.  
  1481.  
  1482.  
  1483.   8.1.  Text to PostScript conversion
  1484.  
  1485.  
  1486.   Sometimes you have just a plain ASCII KOI8-R text and you want to
  1487.   print it just to get it on the paper. One of the easiest ways to
  1488.   achieve that is to use special programs converting text to PostScript.
  1489.  
  1490.   There are a number of programs doing such conversion. I personally
  1491.   prefer a2ps. Originally developed as a simple text-to-PostScript
  1492.   converter it became a big and highly configurable program with many
  1493.   options and allows you to manage various page layouts, syntax
  1494.   highlighting etc. Another tool (now available as a part of the GNU
  1495.   project) is enscript.
  1496.  
  1497.  
  1498.  
  1499.   8.1.1.  An a2ps converter
  1500.  
  1501.  
  1502.   A text to PostScript converter has been around for a while and is one
  1503.   of the most versatile printing tools. The author proved to be very
  1504.   open to suggestions, so since the release 4.9.8 a2ps supports Cyrillic
  1505.   right off-the-shelf. All you need is a PostScript printer.
  1506.  
  1507.   The command I use is:
  1508.  
  1509.  
  1510.   a2ps -X koi8r --print-anyway  <file>
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.   8.1.2.  The GNU enscript
  1520.  
  1521.  
  1522.   The GNU enscript program is also designed for converting text to
  1523.   PostScript and it also has a non-ASCII codeset support. It doesn't
  1524.   have Cyrillic PostScript fonts, but it is very easy to get them, as
  1525.   will be explained below (thanks to Michael Van Canneyt):
  1526.  
  1527.  
  1528.   1. Install the newest enscript. As of now, the most recent release is
  1529.      1.5. You may either get the one from the GNU FTP archive, or take
  1530.      an RPM package from the Redhat site.
  1531.  
  1532.   2. Now, if you are a lucky RedHat Linux user, download and install
  1533.      Cyrillic Textbook font
  1534.      <ftp://ftp.redhat.com/pub/contrib/i386/enscript-fonts-
  1535.      koi8-1.0-1.i386.rpm>.
  1536.  
  1537.   3. If you don't use RPM, download a file textbook.tar.gz from the
  1538.      Cyrillic Software collection on sunsite.unc.edu
  1539.      <ftp://sunsite.unc.edu/pub/academic/russian-studies/Software/>.
  1540.      Extract it to a directory, where enscript fonts are located
  1541.      (usually /usr/share/enscript). Now change to that directory and run
  1542.      the following command:
  1543.  
  1544.  
  1545.          mkafmmap *.afm
  1546.  
  1547.  
  1548.  
  1549.   4. The setup is finished. Try to print some text in KOI8-R Cyrillic
  1550.      with the following command:
  1551.  
  1552.  
  1553.          enscript --font=Textbook8 --encoding=koi8 some.file
  1554.  
  1555.  
  1556.  
  1557.   If you want a really quick and dirty solution and you don't care about
  1558.   the output quality and all you need is just Cyrillic on the paper, try
  1559.   the rtxt2ps package. It is a very simple no-frills text-to-PostScript
  1560.   conversion program. The output quality is not very good (or, to be
  1561.   honest, just bad) but it does it's job.
  1562.  
  1563.  
  1564.  
  1565.   8.2.  Text to TeX conversion
  1566.  
  1567.  
  1568.   If all you need is just to print an ASCII text without any additional
  1569.   word processing, you may try to use some programs, which would convert
  1570.   your Cyrillic text to a ready-to-process TeX file. One of the best
  1571.   programs for such purposes is translit (see section ``''). In this
  1572.   case, you don't even have to bother about installing the Cyrillic
  1573.   fonts for TeX, since translit uses a Washington Cyrillic package,
  1574.   which is included in most TeX distributions (or am I wrong?)
  1575.  
  1576.  
  1577.  
  1578.   9.  Cyrillic in PostScript
  1579.  
  1580.  
  1581.   Experts say PostScript is easy. I cannot judge - I've got too many
  1582.   things to learn to spare some time to learn PostScript. So I'll try to
  1583.   use my sad experience with it. I'll appreciate any feedback from you
  1584.   guys who know more on the subject than I do (approx. 99% of the Earth
  1585.   population).
  1586.  
  1587.   Basically, in order to print a Cyrillic text using PostScript, you
  1588.   have to make sure about the following things:
  1589.  
  1590.  
  1591.   o  Cyrillic font is loaded or included in the document.
  1592.  
  1593.   o  Cyrillic text is included in the document.
  1594.  
  1595.   o  Cyrillic text uses the appropriate character codes which correspond
  1596.      to the font's requirements.
  1597.  
  1598.   o  An appropriate font is selected in order to print Cyrillic text.
  1599.  
  1600.   There is no solution general enough to be recommended as an ultimate
  1601.   treatment. I'll try to outline various ways to cope with different
  1602.   problems related to the subject.
  1603.  
  1604.   One way to address Cyrillic setup problems generally enough is to use
  1605.   Ghostscript. Ghostscript (or just gs in the newspeak) is a free (well
  1606.   quasi-free) PostScript interpreter. It has many advantages; among
  1607.   them:
  1608.  
  1609.  
  1610.   o  Ability to run on many platforms (various Unices, Windows etc)
  1611.  
  1612.   o  Support for a wide number of non-PostScript printers
  1613.  
  1614.   o  Good degree of configurability
  1615.  
  1616.   What is important in our particular case, is that once Ghostscript is
  1617.   set up, we can do all printing through it, thus eliminating extra
  1618.   setup for other PostScript devices (for example HP LaserJet IV)
  1619.  
  1620.  
  1621.  
  1622.   9.1.  Adding Cyrillic fonts to Ghostscript
  1623.  
  1624.  
  1625.   This is important, since you probably don't want to put a
  1626.   responsibility to other programs to insert Cyrillic fonts in the
  1627.   PostScript output. Instead, you add them to gs and just make the
  1628.   programs generate Cyrillic output compatible with the fonts.
  1629.  
  1630.   To add a new font (in pfa or pfb form) in gs, you have to:
  1631.  
  1632.  
  1633.   1. Put it in the gs fonts directory (ie.  /usr/lib/ghostscript/fonts).
  1634.  
  1635.   2. Add the appropriate names and aliases for the font in the Fontmap
  1636.      file in the gs directory.
  1637.  
  1638.   Recently a decent set of Cyrillic fonts for GhostScript appeared.  It
  1639.   is located in ftp.kapella.gpi.ru. This one even has a necessary part
  1640.   to add to the Fontmap file. You have to download the contents of the
  1641.   /pub/cyrillic/psfonts directory. The README file describes the
  1642.   necessary details.
  1643.  
  1644.  
  1645.  
  1646.   10.  Print setup
  1647.  
  1648.  
  1649.   Printing is always tricky. There are different printers from different
  1650.   vendors with different facilities. Even for a native printing there is
  1651.   no uniform solution (this applies not only to UNIX, but to other
  1652.   operating systems as well.
  1653.  
  1654.   Printers have different control languages and often they have very
  1655.   different views on foreign language support.  The good news is that on
  1656.   control language seems to be recognized as a de-facto standard for
  1657.   print job description - it is a PostScript language developed by Adobe
  1658.   Corporation.
  1659.  
  1660.   Another problem is a variety of requirements to the print services.
  1661.   For example, sometimes you want just to print a piece if C program,
  1662.   containing comments in Russian, so you don't need any pretty-printing
  1663.   - just a raw ASCII output in a single font. Another time, when you
  1664.   design a postcard for your girlfriend, you'll probably need to typeset
  1665.   some document with different fonts etc. This will definitely require
  1666.   more effort to setup Cyrillic support.
  1667.  
  1668.   To accomplish the former task you just have to make your printer
  1669.   understand one Cyrillic font and (maybe) install some filter program
  1670.   to generate data in appropriate format. To accomplish the latter one,
  1671.   you have to teach your printer different fonts and have a special
  1672.   software.
  1673.  
  1674.   There is also something in the middle, when you get a program which
  1675.   knows how to generate both the fonts and the appropriate printer
  1676.   input, so you can say do some aource code pretty-printing without
  1677.   sophisticated word processing systems.
  1678.  
  1679.   All these options will be more or less covered below.
  1680.  
  1681.  
  1682.  
  1683.   10.1.  Pre-loading Cyrillic fonts into a non-PostScript printer
  1684.  
  1685.  
  1686.   If you have a good old dot matrix printer and all you need is to print
  1687.   a raw KOI8-R text, try the following:
  1688.  
  1689.  
  1690.   1. Find a proper KOI8-R font for your printer. Check out the MS-DOSish
  1691.      stuff on the Internet (for example the SimTel archive
  1692.      <ftp://ftp.simtel.net>).
  1693.  
  1694.   2. Learn from the manual, how to load such font into your printer and,
  1695.      probably, write a simple program doing that.
  1696.  
  1697.   3. Run this program from the appropriate rc file at a boot time.
  1698.  
  1699.   Thus, having Cyrillic characters in the upper part of the printer's
  1700.   character set will allow you to print you texts in Russian without any
  1701.   hussle.
  1702.  
  1703.   Alternatively to the KOI8-R fonts you may try to use the Alt font.
  1704.   There are two reasons for that:
  1705.  
  1706.  
  1707.   o  It may be probably much easier to find an Alt font, since those
  1708.      were very widespread in the MS-DOS culture.
  1709.  
  1710.   o  Having a proper Alt font will allow you to print pseudo-graphic
  1711.      characters as well.
  1712.  
  1713.   However in this case, you'll have to convert your texts from KOI8-R to
  1714.   Alt before sending them to a printer. This is quite easy, since there
  1715.   are a lot of programs doing that (see ``translit'' for example), so
  1716.   you just have to call such program properly in the if field in
  1717.   /etc/printcap file. For example, with the translit program you may
  1718.   specify:
  1719.  
  1720.  
  1721.  
  1722.   if=/usr/bin/translit -t koi8-alt.rus
  1723.  
  1724.  
  1725.  
  1726.   See printcap(5) for details.
  1727.  
  1728.  
  1729.  
  1730.   10.2.  Printing with different fonts
  1731.  
  1732.  
  1733.   One great way to cope with different printers and fonts is to use TeX
  1734.   (see section ``''). TeX drivers handle all details, so once you make
  1735.   TeX understand Cyrillic fonts, you are done.
  1736.  
  1737.   Another possibility is to use PostScript. I decided to devote an
  1738.   entire chapter ``'' to the subject, since it is not simple.
  1739.  
  1740.   Finally, there are other word processors, which have printer drivers.
  1741.   I never tried anything apart from TeX, so I cannot suggest anything.
  1742.  
  1743.  
  1744.  
  1745.   11.  Localization and Internationalization
  1746.  
  1747.  
  1748.   So far, I described how to make various programs understand Cyrillic
  1749.   text. Basically, each program required it's own method, very different
  1750.   from the others. Moreover, some programs had incomplete support of
  1751.   languages other than English. Not to mention their inability to
  1752.   interact using user's mother tongue instead of English.
  1753.  
  1754.   The problems outlined above are very pressing, since software is
  1755.   rarely developed for home market only. Therefore, rewriting
  1756.   substantial parts of software each time the new international market
  1757.   is approached is very ineffective; and making each program implement
  1758.   it's own proprietary solution for handling different languages is not
  1759.   a great idea in a long term either.
  1760.  
  1761.   Therefore, a need for standardization arises. And the standard shows
  1762.   up.
  1763.  
  1764.   Everything related to the problems above is divided by two basic
  1765.   concepts: localization and internationalization. By localization we
  1766.   mean making programs able to handle different language conventions for
  1767.   different countries. Let me give an example. The way date is printed
  1768.   in the United States is MM/DD/YY. In Russia however, the most popular
  1769.   format is DD.MM.YY. Another issues include time representation,
  1770.   printing numbers and currency representation format. Apart from it,
  1771.   one of the most important aspect of localization is defining the
  1772.   appropriate character classes, that is, defining which characters in
  1773.   the character set are language units (letters) and how they are
  1774.   ordered. On the other hand, localization doesn't deal with fonts.
  1775.  
  1776.   Internationalization (or i18n for brevity) is supposed to solve the
  1777.   problems related to the ability of the program interact with the user
  1778.   in his native language.
  1779.  
  1780.   Both of the concepts above had to be implemented in a standard, giving
  1781.   programmers a consistent way of making the programs aware of national
  1782.   environments.
  1783.   Althogh the standard hasn't been finished yet, many parts actually
  1784.   have; so they can be used without much of a problem.
  1785.  
  1786.   I am going to outline the general scheme of making the programs use
  1787.   the features above in a standard way. Since this deserves a separate
  1788.   document, I'll just try to give a very basic description and pointers
  1789.   to more thorough sources.
  1790.  
  1791.  
  1792.  
  1793.   11.1.  Locale
  1794.  
  1795.  
  1796.   One of the main concept of the localization is a locale. By locale is
  1797.   meant a set of conventions specific to a certain language in a certain
  1798.   country. It is usually wrong to say that locale is just country-
  1799.   specific. For example, in Canada two locales can be defined -
  1800.   Canada/English language and Canada/French language. Moreover,
  1801.   Canada/English is not equivalent to UK/English or US/English, just as
  1802.   Canada/French is not equivalent to France/French or
  1803.   Switzerland/French.
  1804.  
  1805.  
  1806.  
  1807.   11.1.1.  How to use locale
  1808.  
  1809.  
  1810.   Each locale is a special database, defining at least the following
  1811.   rules:
  1812.  
  1813.  
  1814.   1. character classification and conversion
  1815.  
  1816.   2. monetary values representation
  1817.  
  1818.   3. number representation (ie. the decimal character)
  1819.  
  1820.   4. date/time formatting
  1821.  
  1822.  
  1823.   In RedHat 4.1, which I am using there are actually two locale
  1824.   databases: one for the C library (libc) and one for the X libraries.
  1825.   In the ideal case there should be only one locale database for
  1826.   everything.
  1827.  
  1828.   To change your default locale, it is usually enough to set the LANG
  1829.   environment variable. For example, in sh:
  1830.  
  1831.  
  1832.   LANG=ru_RU
  1833.   export LANG
  1834.  
  1835.  
  1836.  
  1837.   Sometimes, you may want to change only one aspect of the locale
  1838.   without affecting the others. For example, you may decide (God knows
  1839.   why) to stick with ru_RU locale, but print numbers according to the
  1840.   standard POSIX one. For such cases, there is a set of environment
  1841.   variables, which you can you to configure specific parts for the
  1842.   current locale. In the last exaple it would be:
  1843.  
  1844.  
  1845.   LANG=ru_RU
  1846.   LC_NUMERIC=POSIX
  1847.   export LANG LC_NUMERIC
  1848.  
  1849.   For the full description of those variables, see locale(7).
  1850.  
  1851.   Now let's be more Linux-specific. Unfortunately, Linux libc version
  1852.   5.3.12, supplied with RedHat 4.1, doesn't have a russian locale. In
  1853.   this case one must be downloaded from the Internet (I don't know the
  1854.   exact address, however).
  1855.  
  1856.   To check, locale for which languages you have, run 'locale -a'. It
  1857.   will list all locale databases, available to libc.
  1858.  
  1859.   Fortunately, Linux community is rapidly moving to the new GNU libc
  1860.   (glibc version 2, which is much more POSIX-compliant and has a proper
  1861.   russian locale. Next "stable" RedHat system will already use glibc.
  1862.  
  1863.   As for the X libraries, they have their own locale database. In the
  1864.   version I am using (XFree86 3.3), there already is a russian locale
  1865.   database. I am not sure about the previous versions. In any case, you
  1866.   may check it by looking into usr/lib/X11/locale/ (on most systems). In
  1867.   my case, there already are subdirectories named koi8-r and even
  1868.   iso8859-5.
  1869.  
  1870.  
  1871.  
  1872.   11.1.2.  Locale-aware programming
  1873.  
  1874.  
  1875.   With locale, program don't have to implement explicitly various
  1876.   character conversion and comparison rules, described above. Instead,
  1877.   they use special API which make use of the rules defined by locale.
  1878.   Also, it is not necessary for program to use the same locale for all
  1879.   rules - it is possible to handle different rules using different
  1880.   locales (although such technique should be strongly discouraged).
  1881.  
  1882.   From the setlocale(3) manual page:
  1883.  
  1884.  
  1885.        A  program  may be made portable to all locales by calling
  1886.        setlocale(LC_ALL, "" ) after program   initialization,  by
  1887.        using  the  values  returned  from a localeconv() call for
  1888.        locale - dependent information and by using  strcoll()  or
  1889.        strxfrm() to compare strings.
  1890.  
  1891.  
  1892.   SunSoft, for example, defines 5 levels of program localization:
  1893.  
  1894.  
  1895.   1. 8-bit clean software. That is, the program calls setlocale(), it
  1896.      doesn't make any assumptions about the 8th bit of each character,
  1897.      it users functions from ctype.h and limits from limits.h, and it
  1898.      takes care about signed/unsigned issues.
  1899.  
  1900.      It is very important not to do any assumption about the character
  1901.      set nature and ordering. The following programming practices must
  1902.      be avoided:
  1903.  
  1904.  
  1905.          if (c >= 'A' && c <= 'Z') {
  1906.              ...
  1907.  
  1908.  
  1909.  
  1910.   Instead, macros from the ctype.h header file are locale-aware and
  1911.   should be used in all such occasions.
  1912.  
  1913.   2. Formats, sorting methods, paper sizes. The program uses strcoll()
  1914.      and strxfrm() instead of strcmp() for strings, it uses time(),
  1915.      localtime(), and strftime()/ for time services, and finally, it
  1916.      uses localeconv() for a proper numbers and currency representation.
  1917.  
  1918.   3. Visible text in message catalogs. The program must isolate all
  1919.      visible text in special message catalogs. Those map strings in
  1920.      English to their translation to other languages. Selection of
  1921.      messages in an appropriate for a particular environment language is
  1922.      done in a way which is completely transparent for both the program
  1923.      and it's user. To make use of those facilities, the program must
  1924.      call gettext() (Sun/POSIX standard), or catgets() (X/Open
  1925.      standard). For more information on that see section ``''.
  1926.  
  1927.  
  1928.   4. EUC/Unicode support. At this level, the program doesn't use the
  1929.      char type. Instead it uses wchar_t, which defines entities big
  1930.      enough to contain Unicode characters. ANSI C defines this data type
  1931.      and an appropriate API.
  1932.  
  1933.  
  1934.   For a more detaled explanation of locale, see, for example (``'') or
  1935.   (``'').
  1936.  
  1937.  
  1938.  
  1939.   11.2.  Internationalization
  1940.  
  1941.  
  1942.   While localization describes, how to adapt a program to a foreign
  1943.   environment, internationalization (or i18n for brevity) details the
  1944.   ways to make program communicate with a non-English speaking user.
  1945.  
  1946.   Before, that was done by developing some abstraction of the messages
  1947.   to output from the program's code. Now, such mechanism is (more or
  1948.   less) standardized. And, of course, there are free implementations of
  1949.   it!
  1950.  
  1951.   The GNU project has finally adopted the way of making the
  1952.   internationalized applications. Ulrich Drepper (drepper@ipd.info.uni-
  1953.   karlsruhe.de) developed a package gettext. This package is available
  1954.   at all GNU sites like prep.ai.mit.edu. It allows you to develop
  1955.   programs in the way that you can easily make them support more
  1956.   languages. I don't intend to describe the programming techniques,
  1957.   especially because the gettext package is delivered with excellent
  1958.   manual.
  1959.  
  1960.   Request for collaboration: If you want to learn the gettext package
  1961.   and to contribute to the GNU project simultaneously; or even if you
  1962.   just want to contribute, then you can do it! GNU goes international,
  1963.   so all the utilities are being made locale-aware. The problem is to
  1964.   translate the messages from English to Russian (and other languages if
  1965.   you'd like). Basically, what one has to do is to get the special .po
  1966.   file consisting of the English messages for a certain utility and to
  1967.   append each message with it's equivalent in Russian. Ultimately, this
  1968.   will make the system speak Russian if the user wants it to! For more
  1969.   details and further directions contact Ulrich Drepper
  1970.   (drepper@ipd.info.uni-karlsruhe.de).
  1971.  
  1972.  
  1973.  
  1974.  
  1975.   12.  Staying compatible
  1976.  
  1977.  
  1978.   Being standard is not the only issue. To be really nice, one has to
  1979.   provide the backward compatibility. In our case, this means that the
  1980.   configuration should be tolerant to the data created using non-
  1981.   standard character sets - that is the Alt (cp866) and cp1251 ones.
  1982.   Also, we should be able to run Cyrillic programs for MS-DOS.
  1983.  
  1984.   In most cases (except for HTTP), it is enough to provide a timely
  1985.   conversion of data to KOI8-R. When we talk about raw unstructured
  1986.   data, it is quite trivial - see section ``Conversion Utilities''.
  1987.  
  1988.   Another issue is the structured data. This case is more tricky. I'll
  1989.   try to outline the basic roadmap of fixing it.
  1990.  
  1991.  
  1992.  
  1993.   12.1.  MIME-based data compatibility
  1994.  
  1995.  
  1996.   MIME is a standard for architecture-independent data representation.
  1997.   Originally developed for mail messages, it has now many more
  1998.   applications. MIME defines format, which is open to extensions and
  1999.   allows architecture-specific handling of data. For example, if I
  2000.   receive a mail message, containing a MIME object of the video/mpeg
  2001.   type (an encoded MPEG file), my mail reader will automatically decode
  2002.   it and start an MPEG player.
  2003.  
  2004.   Most UNIX programs, offering MIME capabilities, are based on the
  2005.   metamail package, which contains a set of utilities and data files to
  2006.   work with MIME objects. Several configuration files (/etc/mailcap for
  2007.   global usage and ~/.mailcap for personal setup) define rules for
  2008.   handling MIME object of various types.
  2009.  
  2010.   Thus, if you receive a proper MIME data stream, containing text in one
  2011.   of the obsolete character sets, you may define a MIME rule to convert
  2012.   such text to KOI8.
  2013.  
  2014.   Below a number of MIME rules are shown, which are supposed to handle
  2015.   plain text and richtext objects, using both of the obsolete codesets,
  2016.   discussed above. You may incorporate these rules into one of the MIME
  2017.   configuration files.
  2018.  
  2019.   Note, that these rules use the translit package to perform the actual
  2020.   conversion. For more information on that program and the conversion in
  2021.   general see section ``Conversion Utilities''.
  2022.  
  2023.  
  2024.   text/plain; translit -t cp1251-koi8.rus < %s; test=test \
  2025.       "`echo %{charset} | tr '[A-Z]' '[a-z]'`"  = cp1251; copiousoutput
  2026.  
  2027.   text/richtext; translit -t cp1251-koi8.rus < %s; test=test \
  2028.       "`echo %{charset} | tr '[A-Z]' '[a-z]'`"  = cp1251; copiousoutput
  2029.  
  2030.   text/plain; translit -t alt-koi8.rus < %s; test=test \
  2031.       "`echo %{charset} | tr '[A-Z]' '[a-z]'`"  = cp866; copiousoutput
  2032.  
  2033.   text/richtext; translit -t alt-koi8.rus < %s; test=test \
  2034.       "`echo %{charset} | tr '[A-Z]' '[a-z]'`"  = cp866; copiousoutput
  2035.  
  2036.   text/plain; translit -t alt-koi8.rus < %s; test=test \
  2037.       "`echo %{charset} | tr '[A-Z]' '[a-z]'`"  = alt; copiousoutput
  2038.  
  2039.   text/richtext; translit -t alt-koi8.rus < %s; test=test \
  2040.       "`echo %{charset} | tr '[A-Z]' '[a-z]'`"  = alt; copiousoutput
  2041.  
  2042.  
  2043.  
  2044.   Obviously enough, this will work for plain text data only. Binary
  2045.   files are supposed to handle the codeset issues themselves (at least
  2046.   their "parent" applications are). Therefore, if you receive a
  2047.   Microsoft Word document in the cp1251 character set, the duty of
  2048.   providing appropriate conversion capabilities lays upon an application
  2049.   you use to read that document (for example Microsoft Word, or Applix
  2050.   Words).
  2051.  
  2052.   Unfortunately, the real situation is not that ideal. Many application
  2053.   have their own idea on how to use MIME. Until recently Microsoft Mail
  2054.   software had a broken MIME engine. Also, the Netscape
  2055.   Navigator/Communicator mail client is notorious because of it's
  2056.   sending of mail messages, encoded in cp1251 with the charset=koi8-r
  2057.   field in the message header and vice versa.
  2058.  
  2059.  
  2060.  
  2061.   12.2.  Explicit character set conversion
  2062.  
  2063.  
  2064.   There are a lot of conversion routines for Cyrillic on the Internet.
  2065.   Each of them has it's own quirks and it's own degree of Cyrillic
  2066.   support.
  2067.  
  2068.   In my opinion tools must be standard. In this particular case the
  2069.   "standard" conversion tool is GNU recode. Unfortunately, the version,
  2070.   found on the official GNU site (3.4) doesn't support Cyrillic yet
  2071.   (only ISO-8859-5). I developed a set of conversion tables for KOI8-R,
  2072.   Alt, and cp1251 for recode and submitted them to the recode
  2073.   maintainer. He promised to provide Cyrillic support in the upcoming
  2074.   release. Once it happens, I'll rewrite this section to recommend GNU
  2075.   recode as the standard conversion engine for Cyrillic.
  2076.  
  2077.   Meanwhile, I would recommend a translit package. It supports many
  2078.   popular codesets and is even able to produce a *TeX files (see section
  2079.   ``'') from text in Russian. Also, RedHat users will enjoy an RPM
  2080.   package for translit.
  2081.  
  2082.   For other conversion routines, Look at SovInformBureau or
  2083.   ftp.funet.fi. You can even use the special mode for emacs (see section
  2084.   ``Emacs'').
  2085.  
  2086.  
  2087.  
  2088.   12.3.  Cyrillic in the DOS emulator
  2089.  
  2090.  
  2091.   This seems to be the only application, which may require Alt Cyrillic
  2092.   character set. The reason is that Alt is native to DOS and most of DOS
  2093.   programs dealing with Cyrillic are Alt-oriented.
  2094.  
  2095.   For the console version (dos) you just have to load a keyboard and
  2096.   screen driver. Most of DOS drivers will work fine. I personally use
  2097.   the rk driver by A. Strakhov, which works for both console and X
  2098.   versions of dosemu. Another choice is the r driver by V. Kurland
  2099.   (sorry for possible misspelling). It is perfectly customizable and
  2100.   supports many codesets, Alt and KOI8 among them. However it won't work
  2101.   for the X window (at least version 1.14 I'm using).
  2102.  
  2103.   Both drivers can be found on most Russian Internet sites, for example
  2104.   Kurchatov Institute FTP server <ftp://ftp.kiae.su/pub/cyrillic/msdos>.
  2105.  
  2106.   For the X version of dosemu you have to provide an appropriate X font
  2107.   as well. Alex Bogdanov sent me such font by e-mail. It is an original
  2108.   vga font from the dosemu distribution, modified for the Alt codeset.
  2109.   Unfortunately I don't know who is the creator of this font and where
  2110.   the official site is.
  2111.  
  2112.  
  2113.   To setup the font for dosemu you should
  2114.  
  2115.  
  2116.   o  Introduce this font to the X. This is described in ``X fonts
  2117.      setup''.
  2118.  
  2119.   o  Introduce this font to dosemu. If the font just replaces the
  2120.      original vga font, then it will be recognized by default.
  2121.      Otherwise, you have to describe it in /etc/dosemu.conf:
  2122.  
  2123.  
  2124.      # Font to use (without filename extensions). For example:
  2125.      X { updatefreq 8 title "MS DOS" icon_name "xdos" font "vga-alt"}
  2126.  
  2127.  
  2128.  
  2129.   Finally, you have to load a keyboard driver. Note, the you don't need
  2130.   a screen driver for the X window. Therefore, not all drivers will
  2131.   work. At least two will: rk by A. Strakhov, and cyrkeyb by Pete
  2132.   Kvitek.
  2133.  
  2134.  
  2135.  
  2136.   13.  Bibliography
  2137.  
  2138.  
  2139.  
  2140.   1. Andrey Chernov. KOI-8 <http://www.nagual.ru/~ache/koi8.html>. KOI-8
  2141.      information and setup.
  2142.  
  2143.   2. Ulrich Drepper. Internationalization in the GNU project
  2144.      <http://i44www.info.uni-karlsruhe.de/~drepper/conf96/paper.html>.
  2145.      Very thorough description of a GNU approach to i18n.
  2146.  
  2147.   3. Michael Karl Gschwind. Internationalization
  2148.      <http://www.vlsivie.tuwien.ac.at/mike/i18n.html>. Various resources
  2149.      on i18n.
  2150.  
  2151.   4. Sergei Naumov. Information on Cyrillic Software
  2152.      <http://sunsite.oit.unc.edu/sergei/Software/Software.html>.
  2153.      Cyrillic setup information.
  2154.  
  2155.   5. The Open Group Single UNIX specification <http://www.UNIX-
  2156.      systems.org/online.html>.
  2157.  
  2158.   6. RFC 1489 RFC 1489 <file://ds.internic.net/rfc/rfc1489.txt>
  2159.  
  2160.   7. Alec Voropay. Localization as it is
  2161.      <http://www.sensi.org/~alec/locale>. General locale usage in
  2162.      Russian.
  2163.  
  2164.  
  2165.  
  2166.  
  2167.   14.  Summary of the various useful resources
  2168.  
  2169.  
  2170.   a2ps homepage <http://www-inf.enst.fr/~demaille/a2ps.html>
  2171.  
  2172.   General Linux Information <http://www.linux.org>
  2173.  
  2174.   Collection of Cyrillic resources
  2175.   <ftp://ftp.ccl.net/pub/central\_eastern\_europe/russian>
  2176.  
  2177.   Cyrillic resources at KIAE <ftp://ftp.kiae.su/cyrillic/>
  2178.  
  2179.   Cyrillic resources at RELCOM <ftp://ftp.relcom.ru/cyrillic/>
  2180.  
  2181.   Cyrillic resources at FUNET
  2182.   <ftp://ftp.funet.fi/pub/culture/russian/comp/>
  2183.  
  2184.   Cronyx <http://www.cronyx.ru> - the creators of Cyrillic fonts for the
  2185.   X Window System.
  2186.  
  2187.   Cyrillic fonts for Ghostscript and StarOffice
  2188.   <ftp://ftp.kapella.gpi.ru/pub/cyrillic/psfonts>
  2189.  
  2190.   Cyrillic fonts for X
  2191.   <ftp://ftp.kiae.su/cyrillic/x11/fonts/xrus-2.1.1-src.tgz>
  2192.  
  2193.   Ghostscript <http://www.cs.wisc.edu/~ghost/index.html>
  2194.  
  2195.   GNU enscript <ftp://prep.ai.mit.edu/pub/gnu>
  2196.  
  2197.   relcom.fido.ru.linux newsgoup.
  2198.  
  2199.   relcom.fido.ru.unix newsgoup.
  2200.  
  2201.   Russian dictionary for GNU ispell <http://www.ispras.ru/~knizhnik>
  2202.  
  2203.   SovInformBureau <http://www.siber.com/sib/russify/>
  2204.  
  2205.   teTeX russification package <ftp://xray.sai.msu.su/pub/outgoing/teTeX-
  2206.   rus/>
  2207.  
  2208.   The kbd package for Linux
  2209.   <ftp://sunsite.unc.edu/pub/Linux/system/Keyboards/>
  2210.  
  2211.   The remap package for Emacs <ftp://ftp.iesd.auc.dk/>
  2212.  
  2213.   The rtxt2ps package <http://www.siber.com/sib/russify/converters/>
  2214.  
  2215.   The russian.el package for emacs
  2216.   <http://www.math.uga.edu/~valery/russian.el>
  2217.  
  2218.   The translit package
  2219.   <ftp://ftp.osc.edu/pub/russian/translit/translit.tar.Z>
  2220.  
  2221.   The xruskb package <ftp://ftp.relcom.ru/pub/x11/cyrillic/>
  2222.  
  2223.   Useful Cyrillic packages <ftp://sunsite.unc.edu/pub/academic/russian-
  2224.   studies/Software>
  2225.  
  2226.   X fonts collections <ftp://ftp.switch.ch/mirror/linux/X11/fonts/>
  2227.  
  2228.   XFree86 FTP site <http://www.xfree86.org>
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.