xterm and locale - Xwindows

This is a discussion on xterm and locale - Xwindows ; Hello, I am trying to to configure xterm to write/read Russian. After googling around, I added the following to the "InputDevice" section of XF86Config: Option "XkbRules" "xfree86" Option "XkbModel" "pc104" Option "XkbLayout" "us,ru" Option "XkbOptions" "grp:ctrl_shift_toggle,grp_led:scroll" Now, I am able ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: xterm and locale

  1. xterm and locale


    Hello,

    I am trying to to configure xterm to write/read Russian.

    After googling around, I added the following to the "InputDevice"
    section of XF86Config:

    Option "XkbRules" "xfree86"
    Option "XkbModel" "pc104"
    Option "XkbLayout" "us,ru"
    Option "XkbOptions" "grp:ctrl_shift_toggle,grp_led:scroll"

    Now, I am able to write in Russian in Mozilla's Navigation Toolbar,
    for example, by pressing Ctrl+Shift.

    But it doesn't work in xterm: though I use cyrillic font with proper
    encoding, when I switch to Russian, xterm stops responding to those keys
    which are supposed to output letters (i.e., I still can use keys like
    Return, Arrows, keys that output numbers etc. as usual).

    I found out that setting "export LANG=ru_RU.koi8r" helps somewhat: if
    there is a file with name that contains cyrillic letters, they are
    shown as codes in ls' listing (for example, filename shown
    as \304\306\345\347\376). When I set LANG, filenames are shown propely,
    but xterm still doesn't respond to letters. Only when I invoke a new
    instance of xterm after setting "export LANG=ru_RU.koi8r" does the xterm
    starts responding to Russian letters.

    Why is that so? AFAIK, locale does not have anything to do with
    input/output and mapping of keycodes to symbols - all it does is
    setting local conventions like date format, sorting order etc. -
    it is X's work to take care of all that, and it actually does (in
    Mozilla's Navigation Toolbar, for example).

    So, to recap:

    1) Why xterm does not let X do the "dirty work" of taking care
    about what to output and how?

    2) Why does setting "LANG" helps, supposedly it has nothing to
    do with the problem?

    3) Are there other ways to solve the problem?


    ddtl.

  2. Re: xterm and locale

    ddtl wrote:
    >
    >Hello,
    >
    >I am trying to to configure xterm to write/read Russian.
    >
    >After googling around, I added the following to the "InputDevice"
    >section of XF86Config:
    >
    >Option "XkbRules" "xfree86"
    >Option "XkbModel" "pc104"
    >Option "XkbLayout" "us,ru"
    >Option "XkbOptions" "grp:ctrl_shift_toggle,grp_led:scroll"
    >
    >Now, I am able to write in Russian in Mozilla's Navigation Toolbar,
    >for example, by pressing Ctrl+Shift.
    >
    >But it doesn't work in xterm: though I use cyrillic font with proper
    >encoding, when I switch to Russian, xterm stops responding to those keys
    >which are supposed to output letters (i.e., I still can use keys like
    >Return, Arrows, keys that output numbers etc. as usual).
    >
    >I found out that setting "export LANG=ru_RU.koi8r" helps somewhat: if
    >there is a file with name that contains cyrillic letters, they are
    >shown as codes in ls' listing (for example, filename shown
    >as \304\306\345\347\376). When I set LANG, filenames are shown propely,
    >but xterm still doesn't respond to letters. Only when I invoke a new
    >instance of xterm after setting "export LANG=ru_RU.koi8r" does the xterm
    >starts responding to Russian letters.
    >
    >Why is that so? AFAIK, locale does not have anything to do with
    >input/output and mapping of keycodes to symbols - all it does is
    >setting local conventions like date format, sorting order etc. -
    >it is X's work to take care of all that, and it actually does (in
    >Mozilla's Navigation Toolbar, for example).
    >
    >So, to recap:
    >
    >1) Why xterm does not let X do the "dirty work" of taking care
    >about what to output and how?


    Most of the intelligence is in the application. The X server actually
    does very little: keys cause events to be delivered and the application
    interprets them. Naturally, it has help from Xlib.

    The X server does propagate a key map, which is what you are influencing
    by setting stuff in XF86Config.

    >2) Why does setting "LANG" helps, supposedly it has nothing to
    >do with the problem?


    The C library definition of LANG has nothing to do with the problem;
    however, Xlib uses it (and other environment variables) to
    parameterize its operation. In particular, an application can choose
    to use an "input method" which handles a particular language. These
    vary widely in scope, from the complex subsystems required for Asian
    languages to the trivial support required for the C locale.

    Unfortunately, most older applications do not handle this properly.

    >3) Are there other ways to solve the problem?


    We are in a period of transition. The "old" method was to use a different
    8-bit character encoding for each language. The "new" method is to use
    wide characters (UCS/UTF) so that all (or nearly all) locales can be
    supported on every computer.

    Russian is one of the "easy" languages since it is based on a phonetic
    alphabet and is widely spoken. It would be reasonable to expect it to be
    well supported in an UTF locale, such as LANG=en_US.utf.

    Xterm handles UTF at present, and eventually most applications will.

    >ddtl.



  3. Re: xterm and locale


    >We are in a period of transition. The "old" method was to use a different
    >8-bit character encoding for each language. The "new" method is to use
    >wide characters (UCS/UTF) so that all (or nearly all) locales can be
    >supported on every computer.
    >
    >Russian is one of the "easy" languages since it is based on a phonetic
    >alphabet and is widely spoken. It would be reasonable to expect it to be
    >well supported in an UTF locale, such as LANG=en_US.utf.
    >
    >Xterm handles UTF at present, and eventually most applications will.


    Thanks for the answer,

    I also just found an interesting resource which explains everything about XKB:

    http://pascal.tsu.ru/other/xkb/

    ddtl.

  4. Re: xterm and locale

    Hi ddtl!

    On 09 May 04 at 20:42, "ddtl" (ddtl ) wrote:

    ddtl> Hello,

    ddtl> Now, I am able to write in Russian in Mozilla's Navigation Toolbar,
    ddtl> for example, by pressing Ctrl+Shift.

    AFAIK Mozilla is based on gtk which is smart enough to use Xkb extension
    of an X server ( which may or may not be present), where xterm is not.
    You can test this statement by disabling Xkb keyboard extension.

    ddtl> I found out that setting "export LANG=ru_RU.koi8r" helps somewhat:

    I am not sure if you spell your cyrillic $LANG correctly, although it
    may be valid. I'd recomment to try 'ru_RU.KOI8-R' which is more standard.
    You can test this by checking result of XSupportsLocale() function under
    the both.

    ddtl> 1) Why xterm does not let X do the "dirty work" of taking care about
    ddtl> what to output and how?

    Define "dirty work".

    ddtl> 2) Why does setting "LANG" helps, supposedly it has nothing to do
    ddtl> with the problem?

    Supposedly, if it helps, then it pretty much has.

    ddtl> 3) Are there other ways to solve the problem?

    Run xev and type in cyrillic mode. If it reports correct characters
    by XLookupString, then it is more of a xterm problem, which is solvable by a
    correct $LANG. Otherwise, it is an X server language setup problem or
    an incorrectly set keyboard map ( man xmodmap ).

    --
    HTH,
    Dmitry

    --- www.karasik.eu.org ---


+ Reply to Thread