Accented Characters

From LQWiki
Jump to navigation Jump to search

Typing Accented and other "foreign language" Characters

There are a number of ways of obtaining accented characters and symbols which are not on the keyboard. Obviously you can only use such a character if there is a least one installed font which contains it.

Choosing the right locale

Check your "locale"! Type (in a terminal)

env|grep LANG

If the result ends in UTF-8, you're OK. If not, you should seriously consider converting your system to Unicode/UTF-8, in order to make it work with all languages of the world.

The AltGr Key

The AltGr key functions like a second Shift key, changing the usage of any key pressed while it is held down. The following account applies to one English-language layout: other systems and languages will differ.

Some characters are produced in two keystrokes: the first indicates that the following character is to be accented, and the second is the character to which the accent is to be applied. The keystroke that produces the accent is called a dead key; the keys that function in this way with AltGr are #, [, ] and =.

  • AltGr + = applies a cedilla (left hook) or comma under certain letters: ç ģ ķ ļ ņ ŗ ş Ç Ģ Ķ Ļ Ŗ Ş
  • AltGr + shift + ' applies a carom (inverted circumflex) to some letters: č ď ľ ň ř š ť ž Č Ď Ľ Ň Ř Š Ť Ž
  • AltGr + shift + = applies an ogonek (right hook) under some vowels: ą ę į ų Ą Ę Į Ų
  • AltGr + shift + \ applies a breve to a: ă Ă
  • AltGr + shift + [ applies a ring to the next A: å Å
  • AltGr + shift + ] applies a macron to the next vowel: ā ē ī ō ū Ā Ē Ī Ō Ū
  • AltGr + shift + / applies a dot above some letters; ḃ ċ ḋ ė ḟ ġ ṁ ṗ ṫ ż Ḃ Ċ Ḋ Ė Ḟ Ġ Ṁ Ṗ Ṫ Ż

You can check what accent a key produces by pressing it twice. The combinations of accent and character can be changed by editing /usr/share/X11/locale/en_US.UTF-8/Compose. If anything fails to work as it should, try making the addition to /etc/X11/xorg.conf described below under Compose Key.

Other characters are produced using a single keystroke. The diagram below shows the relationship between each key and the characters it produces (top row is shifted):

| ¡ ⅛ £ ¼ ⅜ ⅝ ⅞ ™ ± ° ¿ ˛
| ¹ ² ³ € ½ ¾ { [ ] } \ ¸
` 1 2 3 4 5 6 7 8 9 0 - =
  Ω Ł E ® Ŧ ¥ ↑ ı Ø Þ ˚ ¯
  @ ł e ¶ ŧ ← ↓ → ø þ " ~
  Q W E R T Y U I O P [ ]
  Æ § Ð ª Ŋ Ħ J & Ł ˝ ˇ ˘
  æ ß ð đ ŋ ħ j ĸ ł ' ^ `
  A S D F G H J K L ; ' #
  « » ¢ “ ” n µ   · ˙
  < > © ` ' N º × ÷ 
  Z X C V B N M , . /

These combinations can be altered by configuring the keyboard map.

The Compose Key

This is not a Shift key, but is used to signal the operating system that the next two key strokes are to be taken as a code for something else. Thus the sequence Compose + a + e will produce æ.

Some computers (e.g. those from Sun) have a Compose key on their keyboard, but for a PC you must nominate a spare key: one of the Windows keys is the natural choice.

From a desktop like Gnome or KDE, the choice can be made with the system menu. Alternatively, the command xmodmap can be used to define the key (as Multi_key). In general (apart from any desktop being used), the Compose key can be specified in the "Input Device" section of the /etc/X11/xorg.conf file. For instance, the following sets the "right windows" key to be the Compose key:

 Option      "XkbOptions"  "compose:rwin"

A list of compose sequences is in the file /usr/share/X11/locale/en_US.UTF-8/Compose. If you find that some sequences do not work, try adding the line

GTK_IM_MODULE=xim

to the file /etc/environment

Some examples: to get accented letters, use

  • grave, tilde, circumflex keys
  • apostrophe for the acute
  • double-quote for the dieresis
  • period for the over-dot
  • comma for the cedilla
  • semicolon for the ogonek
  • 'c' for the caron

Other combinations are

oa for å -d for đ .i for ı .I for İ ng for ŋ
/o for ø ss for ß th for þ ae for æ oe for œ
co for © e= for € p! for ¶ so for § -y for ¥
!! for ¡ ?? for ¿ << for « >> for » /c for ¢
_a for ª _o for º <’ for ‘ >’ for ’
^0 for ° ^2 for ² xx for × -: for ÷ +- for ±
-( for { (( for [ ++ for # AT for @ // for \

The last line in the chart shows how some useful symbols are still obtainable on non-English keyboards.

Further information can be found at Wikipedia. You can alter compose sequences by re-writing /usr/share/X11/locale/en_US.UTF-8/Compose, or by creating a file called .XCompose in your home directory in the same format.

Character Maps

There are character-selection tools like KDE's kcharselect and Gnome's charmap or the selection box in OpenOffice. The obvious disadvantage is that you have to know where to look: for instance, ‘á’ and ‘à’ are in Latin-1, ‘ā’ is in Latin Extended-A, and ‘ǎ’ in Latin Extended-B! The Gnome map is often worth consulting for its notes and cross-references.

The Gnome Character Palette is a panel applet, described fully in Gnome Help. It enables you to place a number of selected characters, unobtainable from the keyboard, on one or more customised charts, ready for use. Only precomposed character-diacritic combinations can be placed on the palette, but combining diacritics can be put there and applied to the base letters in your text.

See also