Re: Latin character set (OFF-TOPIC)

From: Grega Bremec <gregab(at)noviforum(dot)si>
To: Sidar Lopez Cruz <sidarlopez(at)hotmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Latin character set (OFF-TOPIC)
Date: 2003-06-28 13:26:53
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

...and on Fri, Jun 27, 2003 at 04:17:34PM -0600, Sidar Lopez Cruz used the keyboard:
> how do i get support for latin character on my psql console
> :-) Sidar Lopez Cruz
> - Cero Riesgo, S.A.

That's a tricky question, given the amount of information you've given.

I shall assert you aren't referring to the character set used by a database,
since that is easily accomplished using the CREATE DATABASE statement:

Description: Creates a new database
[ WITH [ LOCATION = 'dbpath' ]
[ TEMPLATE = template ]
[ ENCODING = encoding ] ]

Now as for console support for ISO-8859-x encodings, it has a lot more to
do with your operating system than it does with PostgreSQL, and it varies
wildly from OS to OS and even environment to environment.

I shall outline two Linux examples, since this is what I'm most familiar
with, see your respective OS' documentation if that is not the case for

a) text console:

There are two commands related to using other character sets in the
text console: loadkeys and setfont.

Loadkeys will change your keyboard map to one supporting the appropriate
character set, thus enabling you to input characters not found in latin1:

$ loadkeys slovene
Loading /usr/lib/kbd/keymaps/i386/qwertz/

See /usr/lib/kbd/keymaps/ for a list of keymaps installed on your system.
(the exact location may be different depending on your distribution, see
/usr/share/kbd/keymaps/, which is the one used quite frequently too)

Alas, this still doesn't give you support for displaying ISO/latin2
characters, they usually appear as small white rectangles, until you
load a proper font using setfont:

$ setfont lat2-08

This will load a latin2 font of pixel size 8 from
/usr/lib/kbd/consolefonts/ or wherever your OS keeps them (see above).

You should now be able to input and display latin2 characters. In the
case of your locality, see respective keymaps/consolefonts.

b) X window console:

The situation is a bit trickier here, since you need to instruct the
X server to switch modmaps for all X clients to a different one, and
instruct the specific application in question to use a different font.
Luckily, there are also preset keymaps available for X and fonts can
easily be added via use of the "xset" application if they aren't
available yet. Luckily enough, most UNIXoid systems use a windowing
system based on the X11R6 release of The Open Group, so things are
a bit more standard here.

There are several ways of doing it, I shall outline the simplest one
that enables you to alter your keyboard map and use a different font
without restarting the X server.

The tool to switch keyboard mappings is called setxkbmap. It requires
the XKB extension to be enabled in the X server. You can check for that
using the xdpyinfo program and checking the (rather long) output it
gives you:

$ xdpyinfo
number of extensions: 30

If this extension is not present, you need to fix your XF86Config file
according to what is specified below. Now, given you have XKB enabled,
setxkbmap is as straightforward to use as loadkeys:

$ setxkbmap si

That's it! You just managed to convince the X server you have a
Slovene keyboard mapping. If your mapping is different, take a look at
/usr/X11R6/lib/X11/xkb/symbols.dir for a list of available keymaps.

Should you want to make those changes permanent, you will most probably
want to fix the /etc/X11/XF86Config (or according) file on your system
to make the X server boot in the appropriate mode. The settings you need
to change/add are marked with a "+" sign at the beginning of the line:

Section "InputDevice"
Identifier "My keyboard"
Driver "Keyboard"

Option "AutoRepeat" "100 30"

+ Option "XkbModel" "pc105"
+ Option "XkbRules" "xfree86"
+ Option "XkbVariant" "nodeadkeys"
+ Option "XkbOptions" "default"
+ Option "XkbKeycodes" "xfree86"
+ Option "XkbTypes" "default"
+ Option "XkbCompat" "default"
+ Option "XkbSymbols" "us(pc101)"
+ Option "XkbGeometry" "pc"
+ Option "XkbLayout" "si"


The "XkbLayout" is the option that selects your keyboard layout, and it
accepts the same arguments as setxkbmap does.

Fonts are a bit trickier though, because you need to find an X resource
that will affect the font your client application is using. In the case
of xterm though, it's easy enough; if you search the xterm manpage for
string "font", you shall find it soon enough:

font (class Font)
Specifies the name of the normal font. The default is

So, what this means is, you just find out what font you would like to
use with the help of, f.e. xfontsel, and do the following:

$ echo 'xterm*font: ' \
'-misc-fixed-medium-r-normal-' \
'-10-0-*-*-*-0-iso8859-2' >> \

(note: the above example was broken for clarity, however, pasting
the text into the shell should work as displayed; join the
strings within single quotes into one string if unsure)

and run xrdb to merge this with your current resources:

$ xrdb -merge ~/.Xresources

You need to restart any current running xterm client to make it aware
of the new settings.

You don't need to re-run the xrdb command in later X window sessions,
because xinit usually takes care of it automatically by sourcing your
~/.Xresources or ~/.Xdefaults file.

See for a more in-depth
description of setting up international keyboards in the X Window system
using Xmodmap and XKB.

Hope this helps,
Grega Bremec
System Administration & Development Support

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message weigelt 2003-06-28 21:42:32 Re: replication/redundancy
Previous Message Grega Bremec 2003-06-28 13:23:12 Re: Latin character set (OFF-TOPIC)