PDA

View Full Version : HOWTO: Encoding // Pure Terminal // Virtual Terminal


vermaden
05-05-2008, 11:44 AM
Purpose of this HOWTO is to show how to setup properly Pure [ISO] and Virtual Terminals with syscons + xterm + urxvt + screen with English Language for manuals, commands and so, but withcorrectly displaing localized characters.

This example is based on polish language/characters, but may also be used with any other language, just change pl_PL.ISO8895-2 to You proper encoding.

Result of properly set localization [these characters are displayed and typed correctly]:
ę ó ą ś ł ż ź ć ń

We have to face little conflict, ISO under Pure Terminal and UTF8 under Virtual Terminal.

PURE TERMINAL // en_US.ISO-8859-1
Pure text terminal localization is very clean and easy:

/etc/rc.conf
# polish terminal settings // choose yours using sysinstall for example
font8x8="iso02-8x8"
font8x14="iso02-8x14"
font8x16="iso02-8x16"
keymap="pl_PL.ISO8859-2"
scrnmap="NO"

/etc/ttys
# polish virtual terminals // choose yours using sysinstall for example
ttyv0 "/usr/libexec/getty Pc" cons25l2 on secure
ttyv1 "/usr/libexec/getty Pc" cons25l2 on secure
ttyv2 "/usr/libexec/getty Pc" cons25l2 on secure
ttyv3 "/usr/libexec/getty Pc" cons25l2 on secure

PURE TERMINAL + SCREEN // en_US.ISO-8859-1
Also screen under pure terminal displays encodings fine but needs also this setting:
/etc/zprofile /etc/profile /etc/csh.login
LC_ALL=en_US.ISO8859-1

VIRTUAL TERMINAL [X11] +/- SCREEN // en_US.UTF-8

Setting encoding/localizing X11 Virtual Terminal is little enigmatic to me, although I have found a way to have it localized properly. For example I need to export LC_ALL=en_US.UTF-8 in ~/.xinitrc file which is very strange to me.

~/.xinitrc
export LC_ALL=en_US.UTF-8

exec fluxbox

/etc/zprofile /etc/profile /etc/csh.login
LC_ALL=en_US.UTF-8

~/.Xdefaults
urxvt.imLocale: en_US.UTF-8

So we have a problem, we cannot set LC_ALL both to en_US.UTF-8 and to en_US.ISO8859-1 :/ we also cannot use $TERM varible to set our encoding properly, because $TERM will be changed by screen to screen, so this will not work:

/etc/zprofile /etc/profile /etc/csh.login
case "$TERM" in
cons25*|linux)
export LC_ALL=en_US.ISO8859-1
;;
*rxvt*|*xterm*)
export LC_ALL=en_US.UTF-8
;;
screen)
export LC_ALL=en_US.UTF-8
;;
esac

The sollution is to check for terminal speed [at least it works for me]:
Pure Terminal speed:
% stty|grep speed
speed 115200 baud;

Virtual Terminal speed:
% stty|grep speed
speed 38400 baud;

final setup based on terminal speed:

/etc/zprofile /etc/profile /etc/csh.login
if [[ `stty|grep speed|cut -d ' ' -f 2` == 115200 ]]; then
# pure console
export LC_ALL=en_US.ISO8859-1
else # speed 38400
# terminal emulator
export LC_ALL=en_US.UTF-8
fi

these files remain the same as showed upper:
[U]/etc/rc.conf
/etc/ttys
~/.Xdefaults
~/.xinitrc

EDIT:
I gorgot to add one of the key files and realized that NOW :eek:

keyboard entry in /etc/X11/xorg.conf must be:
Section "InputDevice"
Identifier ...
Driver ...
...
Option "XkbModel" "pc105"
Option "XkbLayout" "pl"
EndSection




Of course You will need to change all export words to setenv and also remove '=' if You use csh/tcsh shell, but {t}csh users know that ;)

I am curious if this setup can be achieved in some other, maybe better way, how You deal with these conflicts, ISO vs UTF and xterm vs cons using screen and so?