Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 214981 - sys-apps/openrc: console font & keymaps should disable UTF-8 when UNICODE=no
Summary: sys-apps/openrc: console font & keymaps should disable UTF-8 when UNICODE=no
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: OpenRC Team
Depends on:
Reported: 2008-03-26 21:21 UTC by Thomas
Modified: 2016-01-08 15:30 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Thomas 2008-03-26 21:21:10 UTC
Since kernel 2.6.24 the default of the consoles have changed to UTF-8.  UNICODE=no and LANG=de_DE is not handled correctly since.

The default kbd_mode is UTF-8.

Reproducible: Always

Steps to Reproduce:
1. Boot kernel 2.6.24 with UNICODE=no, log in on console
2. $ kbd_mode
3. $ touch bla && LANG=de_DE ls -l bla

Actual Results:  
ad 2: The keyboard is in Unicode (UTF-8) mode
ad 3: -rw-r--r-- 1 tom users 0 26. M?r 22:10 bla

Expected Results:  
ad 2: The keyboard is in default (ASCII) mode
ad 3: -rw-r--r-- 1 tom users 0 26. Mär 22:10 bla

The init scripts (/etc/init.d/{keymaps,consolefont}),  should explicitly switch back to ASCII / ISO mode.  This currently seems to be impossible due to bug 9139 of the kernel.

Portage (default-linux/amd64/2007.0, gcc-4.1.2, glibc-2.6.1-r0, 2.6.24-gentoo-r3 x86_64)
System uname: 2.6.24-gentoo-r3 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4000+
Timestamp of tree: Wed, 26 Mar 2008 18:30:01 +0000
app-shells/bash:     3.2_p17-r1
dev-java/java-config: 1.3.7, 2.1.4
dev-lang/python:     2.4.4-r6
dev-python/pycrypto: 2.0.1-r6
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.23-r3
CFLAGS="-O2 -fno-strict-aliasing -march=athlon64 -pipe"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/init.d /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -fno-strict-aliasing -march=athlon64 -pipe"
FEATURES="distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"
LINGUAS="de de_DE en en_US en_GB"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
USE="3dnow X a52 aac acpi alsa amd64 berkdb bzip2 cdda cddb cdr cli cracklib crypt cups dbus dri dts dvd dvdr emacs expat flac fontconfig gdbm gif gimpprint gnome gnutls graphviz gs gtk hal iconv imlib isdnlog ithreads jpeg jpeg2k lcms logrotate mad mbox midi mmx mng mp3 mpeg mudflap ncurses nls nptl nptlonly nsplugin ogg opengl openmp pam pango pcre perl png ppds pppd python readline reflection sdl session smp sndfile spl sse sse2 ssl svg tcpd threads tiff truetype unicode v4l vim-syntax vorbis wxwindows x264 xml xorg xpm xprint xv zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de de_DE en en_US en_GB" USERLAND="GNU" VIDEO_CARDS="fglrx nv nvidia radeon v4l"
Comment 1 Thomas 2008-03-26 21:25:08 UTC
The kernel parameter vt.default_utf8=0 switches back to ASCII / ISO as default.
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2008-03-26 21:42:48 UTC
As noted on the upstream bug, this is not a kernel issue.
Comment 3 Roy Marples 2008-03-27 14:08:56 UTC
If you set a keymap then the unicode setting will always be respected regardless of baselayout version. However, some baselayouts did not set terminal encoding correct, and I can't remember when I fixed it. It's safe to say that openrc does it correctly.

openrc-0.3 will be able to set encoding independently of keymaps to make things easier.
Comment 4 Thomas 2008-03-27 14:25:51 UTC
(In reply to comment #3)
> If you set a keymap then the unicode setting will always be respected

This is only correct for the pre 2.6.24 default: If the keyboard is in ASCII mode, it is correctly switched to unicode.  If, however, the keyboard is in unicode mode by default, it is not switched back.

In 2.6.24-r3 i have not found any way to switch a console in unicode mode back to ASCII mode.  It always expects output to be UTF-8, so if the keyboard is switched to ASCII and e. g. Umlauts are entered, they are not displayed correctly.  This is probably a kernel bug.
Comment 5 Roy Marples 2008-03-27 16:25:06 UTC
To change tty1 to ASCII
printf "\033%s" "%@" >/dev/tty1
kbd_mode -a -C /dev/tty1

To change tty1 to UTF-8
printf "\033%s" "%G" >/dev/tty1
kbd_mode -u -C /dev/tty1

Change /dev/tty1 to the terminal you want to change.
If that fails to work, then yes it's a kernel bug.
Comment 6 Thomas 2008-03-27 17:53:54 UTC
(In reply to comment #5)
> To change tty1 to ASCII
> printf "\033%s" "%@" >/dev/tty1
> kbd_mode -a -C /dev/tty1
> ...
> If that fails to work, then yes it's a kernel bug.

Both of these work as expected, so no kernel bug here.

$ echo 0 > /sys/module/vt/parameters/default_utf8

does not have an effect, however.  Wasn't it supposed to do the same?
Comment 7 Roy Marples 2008-03-27 17:57:51 UTC
(In reply to comment #6)
> Both of these work as expected, so no kernel bug here.
> $ echo 0 > /sys/module/vt/parameters/default_utf8
> does not have an effect, however.  Wasn't it supposed to do the same?

I would guess that only applies to newly created terminals, not existing ones.
Comment 8 JZd 2009-04-03 11:11:25 UTC
This is a change in default kernel behaviour.
The solution is to make the vt settings at boot time.
I suggest adding the following lines into /etc/init.d/bootmisc :

if [ -f "/sys/module/vt/parameters/default_utf8" ]; then
  ebegin "Disabling terminal UTF-8 default setting \
          (`/bin/cat /sys/module/vt/parameters/default_utf8`)"
  echo 0 > "/sys/module/vt/parameters/default_utf8"
  eend 0
  ewarn "Cannot disable terminal UTF-8 default setting \
         (/sys/module/vt/parameters/default_utf8 missing)"

No other change has to be made, I use the same settings (/etc/conf.d/consolefont) as before (kernel 2.6.23 r9).

Tested on 2.6.27-gentoo-r8, ISO-8859-2, CONSOLEFONT="lat2-16".
Comment 9 SpanKY gentoo-dev 2016-01-08 03:23:41 UTC
ASCII only defines bytes 0x00 to 0x7F, and they're the same as UTF-8.  other encodings, like ISO-8859-1, define 0x80 - 0xFF differently from UTF-8, and that includes ä.

LANG=de_DE does not declare an encoding.  i'm guessing you're using ISO-8859-1 though as that is usually the default.
Comment 10 Thomas 2016-01-08 15:30:53 UTC
Happy new Year!  (Now this was a long period of silence... ;-)
Yes, the default for de_DE is ISO-8859-1.
I even run some machines with UNICODE=no still (and use the kernel parameter there).