Re: Unicode support under Linux

From: Markus Kuhn (Markus.Kuhn@cl.cam.ac.uk)
Date: Tue Jan 12 1999 - 14:40:55 EST


Nelson Minar wrote on 1999-01-12 16:20 UTC:
> >The obscurity of how to activate UTF-8 in the Linux console has caused
> >this feature to be mostly unused so far.
>
> I think this should be easy to remedy - just write a little program
> called "setutf8" that echos the right sequence and sets up the
> keyboard, then contribute it to the maintainer of the kbd package.

Here is the tiny "utf-8" Perl script that I use for that purpose:

#!/usr/bin/perl
if ($ARGV[0] eq 'on') {
    print "\x1b%G"; # ISO 2022 code for switch to UTF-8 with standard return
    if (`tty` =~ /^\/dev\/tty\d+$/) { # test for linux console
        system("kbd_mode -u"); # set keyboard also to UTF-8 mode
    }
} elsif ($ARGV[0] eq 'off') {
    print "\x1b%@"; # ISO 2022 code for standard return
    if (`tty` =~ /^\/dev\/tty\d+$/) {
        system("kbd_mode -a"); # set keyboard back to normal ASCII/XLATE mode
    }
} else {
    $0 =~ /[^\/]*$/;
    print "usage: $& [on|off]\n";
}

Use it with "utf-8 on" and "utf-8 off".

Markus

-- 
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org,  WWW: <http://www.cl.cam.ac.uk/~mgk25/>



This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:20:44 EDT