/[gentoo]/xml/htdocs/doc/en/utf-8.xml
Gentoo

Contents of /xml/htdocs/doc/en/utf-8.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download) (as text)
Sun May 29 16:00:59 2005 UTC (9 years, 3 months ago) by swift
Branch: MAIN
Changes since 1.14: +2 -2 lines
File MIME type: application/xml
Fix typo (#94339)

1 <?xml version='1.0' encoding="UTF-8"?>
2 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/utf-8.xml,v 1.14 2005/05/09 14:05:46 swift Exp $ -->
3 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4
5 <guide link="/doc/en/utf-8.xml">
6 <title>Using UTF-8 with Gentoo</title>
7
8 <author title="Author">
9 <mail link="slarti@gentoo.org">Thomas Martin</mail>
10 </author>
11 <author title="Contributor">
12 <mail link="devil@gentoo.org.ua">Alexander Simonov</mail>
13 </author>
14
15 <abstract>
16 This guide shows you how to set up and use the UTF-8 Unicode character set with
17 your Gentoo Linux system, after explaining the benefits of Unicode and more
18 specifically UTF-8.
19 </abstract>
20
21 <license />
22
23 <version>2.0</version>
24 <date>2005-05-08</date>
25
26 <chapter>
27 <title>Character Encodings</title>
28 <section>
29 <title>What is a Character Encoding?</title>
30 <body>
31
32 <p>
33 Computers do not understand text themselves. Instead, every character is
34 represented by a number. Traditionally, each set of numbers used to represent
35 alphabets and characters (known as a coding system, encoding or character set)
36 was limited in size due to limitations in computer hardware.
37 </p>
38
39 </body>
40 </section>
41 <section>
42 <title>The History of Character Encodings</title>
43 <body>
44
45 <p>
46 The most common (or at least the most widely accepted) character set is
47 <b>ASCII</b> (American Standard Code for Information Interchange). It is widely
48 held that ASCII is the most successful software standard ever. Modern ASCII
49 was standardised in 1986 (ANSI X3.4, RFC 20, ISO/IEC 646:1991, ECMA-6) by the
50 American National Standards Institute.
51 </p>
52
53 <p>
54 ASCII is strictly seven-bit, meaning that it uses bit patterns representable
55 with seven binary digits, which provides a range of 0 to 127 in decimal. These
56 include 32 non-visible control characters, most between 0 and 31, with the
57 final control character, DEL or delete at 127. Characters 32 to 126 are
58 visible characters: a space, punctuation marks, Latin letters and numbers.
59 </p>
60
61 <p>
62 The eighth bit in ASCII was originally used as a parity bit for error checking.
63 If this is not desired, it is left as 0. This means that, with ASCII, each
64 character is represented by a single byte.
65 </p>
66
67 <p>
68 Although ASCII was enough for communication in modern English, in other
69 European languages that include accented characters, things were not so easy.
70 The ISO 8859 standards were developed to meet these needs. They were backwards
71 compatible with ASCII, but instead of leaving the eighth bit blank, they used
72 it to allow another 127 characters in each encoding. ISO 8859's limitations
73 soon came to light, and there are currently 15 variants of the ISO 8859
74 standard (8859-1 through to 8859-15). Outside of the ASCII-compatible byte
75 range of these character sets, there is often conflict between the letters
76 represented by each byte. To complicate interoperability between character
77 encodings further, Windows-1252 is used in some versions of Microsoft Windows
78 instead for Western European languages. This is a superset of ISO 8859-1,
79 however it is different in several ways. These sets do all retain ASCII
80 compatibility, however.
81 </p>
82
83 <p>
84 The necessary development of completely different single-byte encodings for
85 non-Latin alphabets, such as EUC (Extended Unix Coding) which is used for
86 Japanese and Korean (and to a lesser extent Chinese) created more confusion,
87 while other operating systems still used different character sets for the same
88 languages, for example, Shift-JIS and ISO-2022-JP. Users wishing to view
89 cyrillic glyphs had to choose between KOI8-R for Russian and Bulgarian or
90 KOI8-U for Ukrainian, as well as all the other cyrillic encodings such as the
91 unsuccessful ISO 8859-5, and the common Windows-1251 set. All of these
92 character sets broke most compatibility with ASCII (although KOI8 encodings
93 place cyrillic characters in Latin order, so in case the eighth bit is
94 stripped, text is still decipherable on an ASCII terminal through case-reversed
95 transliteration.)
96 </p>
97
98 <p>
99 This has led to confusion, and also to an almost total inability for
100 multilingual communication, especially across different alphabets. Enter
101 Unicode.
102 </p>
103
104 </body>
105 </section>
106 <section>
107 <title>What is Unicode?</title>
108 <body>
109
110 <p>
111 Unicode throws away the traditional single-byte limit of character sets. It
112 uses 17 "planes" of 65,536 code points to describe a maximum of 1,114,112
113 characters. As the first plane, aka. "Basic Multilingual Plane" or BMP,
114 contains almost everything you will ever use, many have made the wrong
115 assumption that Unicode was a 16-bit character set.
116 </p>
117
118 <p>
119 Unicode has been mapped in many different ways, but the two most common are
120 <b>UTF</b> (Unicode Transformation Format) and <b>UCS</b> (Universal Character
121 Set). A number after UTF indicates the number of bits in one unit, while the
122 number after UCS indicates the number of bytes. UTF-8 has become the most
123 widespread means for the interchange of Unicode text as a result of its
124 eight-bit clean nature, and it is the subject of this document.
125 </p>
126
127 </body>
128 </section>
129 <section>
130 <title>UTF-8</title>
131 <body>
132
133 <p>
134 UTF-8 is a variable-length character encoding, which in this instance means
135 that it uses 1 to 4 bytes per symbol. So, the first UTF-8 byte is used for
136 encoding ASCII, giving the character set full backwards compatibility with
137 ASCII. UTF-8 means that ASCII and Latin characters are interchangeable with
138 little increase in the size of the data, because only the first bit is used.
139 Users of Eastern alphabets such as Japanese, who have been assigned a higher
140 byte range are unhappy, as this results in as much as a 50% redundancy in their
141 data.
142 </p>
143
144 </body>
145 </section>
146 <section>
147 <title>What UTF-8 Can Do for You</title>
148 <body>
149
150 <p>
151 UTF-8 allows you to work in a standards-compliant and internationally accepted
152 multilingual environment, with a comparatively low data redundancy. UTF-8 is
153 the preferred way for transmitting non-ASCII characters over the Internet,
154 through Email, IRC or almost any other medium. Despite this, many people regard
155 UTF-8 in online communication as abusive. It is always best to be aware of the
156 attitude towards UTF-8 in a specific channel, mailing list or Usenet group
157 before using <e>non-ASCII</e> UTF-8.
158 </p>
159
160 </body>
161 </section>
162 </chapter>
163
164 <chapter>
165 <title>Setting up UTF-8 with Gentoo Linux</title>
166 <section>
167 <title>Finding or Creating UTF-8 Locales</title>
168 <body>
169
170 <p>
171 Now that you understand the principles behind Unicode, you're ready to start
172 using UTF-8 with your system.
173 </p>
174
175 <p>
176 The preliminary requirement for UTF-8 is to have a version of glibc installed
177 that has national language support. The recommend means to do this is the
178 <path>/etc/locales.build</path> file in combination with the <c>userlocales</c>
179 USE flag. It is beyond the scope of this document to explain the usage of this
180 file though, luckily, the usage of this file is well documented in the comments
181 within it. It is also explained in the <uri
182 link="/doc/en/guide-localization.xml#doc_chap3_sect3"> Gentoo Localisation
183 Guide</uri>.
184 </p>
185
186 <p>
187 Next, we'll need to decide whether a UTF-8 locale is already available for our
188 language, or whether we need to create one.
189 </p>
190
191 <pre caption="Checking for an existing UTF-8 locale">
192 <comment>(Replace "en_GB" with your desired locale setting)</comment>
193 # <i>locale -a | grep 'en_GB'</i>
194 en_GB
195 en_GB.UTF-8
196 </pre>
197
198 <p>
199 From the output of this command line, we need to take the result with a suffix
200 similar to <c>.UTF-8</c>. If there is no result with a suffix similar to
201 <c>.UTF-8</c>, we need to create a UTF-8 compatible locale.
202 </p>
203
204 <note>
205 Only execute the following code listing if you do not have a UTF-8 locale
206 available for your language.
207 </note>
208
209 <pre caption="Creating a UTF-8 locale">
210 <comment>(Replace "en_GB" with your desired locale setting)</comment>
211 # <i>localedef -i en_GB -f UTF-8 en_GB.UTF-8</i>
212 </pre>
213
214 <p>
215 Another way to include a UTF-8 locale is to add it to the
216 <path>/etc/locales.build</path> file and rebuild <c>glibc</c> with the
217 <c>userlocales</c> USE flag set.
218 </p>
219
220 <pre caption="Line in /etc/locales.build">
221 en_GB.UTF-8/UTF-8
222 </pre>
223
224 </body>
225 </section>
226 <section>
227 <title>Setting the Locale</title>
228 <body>
229
230 <p>
231 There are two environment variables that need to be set in order to use
232 our new UTF-8 locales: <c>LANG</c> and <c>LC_ALL</c>. There are also
233 many different ways to set them; some people prefer to only have a UTF-8
234 environment for a specific user, in which case they set them in their
235 <path>~/.profile</path> or <path>~/.bashrc</path>. Others prefer to set the
236 locale globally. One specific circumstance where the author particularly
237 recommends doing this is when <path>/etc/init.d/xdm</path> is in use, because
238 this init script starts the display manager and desktop before any of the
239 aforementioned shell startup files are sourced, and so before any of the
240 variables are in the environment.
241 </p>
242
243 <p>
244 Setting the locale globally should be done using
245 <path>/etc/env.d/02locale</path>. The file should look something like the
246 following:
247 </p>
248
249 <pre caption="Demonstration /etc/env.d/02locale">
250 <comment>(As always, change "en_GB.UTF-8" to your locale)</comment>
251 LC_ALL="en_GB.UTF-8"
252 LANG="en_GB.UTF-8"
253 </pre>
254
255 <p>
256 Next, the environment must be updated with the change.
257 </p>
258
259 <pre caption="Updating the environment">
260 # <i>env-update</i>
261 >>> Regenerating /etc/ld.so.cache...
262 * Caching service dependencies ...
263 # <i>source /etc/profile</i>
264 </pre>
265
266 <p>
267 Now, run <c>locale</c> with no arguments to see if we have the correct
268 variables in our environment:
269 </p>
270
271 <pre caption="Checking if our new locale is in the environment">
272 # <i>locale</i>
273 LANG=en_GB.UTF-8
274 LC_CTYPE="en_GB.UTF-8"
275 LC_NUMERIC="en_GB.UTF-8"
276 LC_TIME="en_GB.UTF-8"
277 LC_COLLATE="en_GB.UTF-8"
278 LC_MONETARY="en_GB.UTF-8"
279 LC_MESSAGES="en_GB.UTF-8"
280 LC_PAPER="en_GB.UTF-8"
281 LC_NAME="en_GB.UTF-8"
282 LC_ADDRESS="en_GB.UTF-8"
283 LC_TELEPHONE="en_GB.UTF-8"
284 LC_MEASUREMENT="en_GB.UTF-8"
285 LC_IDENTIFICATION="en_GB.UTF-8"
286 LC_ALL=en_GB.UTF-8
287 </pre>
288
289 <p>
290 That's everything. You are now using UTF-8 locales, and the next hurdle is the
291 configuration of the applications you use from day to day.
292 </p>
293
294 </body>
295 </section>
296 </chapter>
297
298 <chapter>
299 <title>Application Support</title>
300 <section>
301 <body>
302
303 <p>
304 When Unicode first started gaining momentum in the software world, multibyte
305 character sets were not well suited to languages like C, in which many of the
306 day-to-day programs people use are written. Even today, some programs are not
307 able to handle UTF-8 properly. Fortunately, most are!
308 </p>
309
310 </body>
311 </section>
312 <section>
313 <title>Filenames, NTFS, and FAT</title>
314 <body>
315
316 <p>
317 There are several NLS options in the Linux kernel configuration menu, but it is
318 important to not become confused! For the most part, the only thing you need to
319 do is to build UTF-8 NLS support into your kernel, and change the default NLS
320 option to utf8.
321 </p>
322
323 <pre caption="Kernel configuration steps for UTF-8 NLS">
324 File Systems --&gt;
325 Native Language Support --&gt;
326 (utf8) Default NLS Option
327 &lt;*&gt; NLS UTF8
328 <comment>(Also &lt;*&gt; other character sets that are in use in
329 your FAT filesystems or Joilet CD-ROMs.)</comment>
330 </pre>
331
332 <p>
333 If you plan on mounting NTFS partitions, you may need to specify an <c>nls=</c>
334 option with mount. For more information, see <c>man mount</c>.
335 </p>
336
337 <p>
338 For changing the encoding of filenames, <c>app-text/convmv</c> can be used.
339 </p>
340
341 <pre caption="Example usage of convmv">
342 # <i>emerge --ask app-text/convmv</i>
343 # <i>convmv -f current-encoding -t utf-8 filename</i>
344 </pre>
345
346 <p>
347 For changing the <e>contents</e> of files, use the <c>iconv</c> utility,
348 bundled with <c>glibc</c>:
349 </p>
350
351 <pre caption="Example usage of iconv">
352 <comment>(substitute iso-8859-1 with the charset you are converting from)</comment>
353 <comment>(Check the output is sane)</comment>
354 # <i>iconv -f iso-8859-1 -t utf-8 filename</i>
355 <comment>(Convert a file, you must create another file)</comment>
356 # <i>iconv -f iso-8859-1 -t utf-8 filename > newfile</i>
357 </pre>
358
359 <p>
360 <c>app-text/recode</c> can also be used for this purpose.
361 </p>
362
363 </body>
364 </section>
365 <section>
366 <title>The System Console</title>
367 <body>
368
369 <impo>
370 You need >=sys-apps/baselayout-1.11.9 for Unicode on the console.
371 </impo>
372
373 <p>
374 To enable UTF-8 on the console, you should edit <path>/etc/rc.conf</path> and
375 set <c>UNICODE="yes"</c>, and also read the comments in that file -- it is
376 important to have a font that has a good range of characters if you plan on
377 making the most of Unicode.
378 </p>
379
380 <p>
381 The <c>KEYMAP</c> variable, set in <path>/etc/conf.d/keymaps</path>, should
382 have a Unicode keymap specified. To do this, simply prepend the keymap already
383 specified there with -u.
384 </p>
385
386 <pre caption="Example /etc/conf.d/keymaps snippet">
387 <comment>(Change "uk" to your local layout)</comment>
388 KEYMAP="-u uk"
389 </pre>
390
391 </body>
392 </section>
393 <section>
394 <title>Ncurses and Slang</title>
395 <body>
396
397 <note>
398 Ignore any mention of Slang in this section if you do not have it installed or
399 do not use it.
400 </note>
401
402 <p>
403 It is wise to add <c>unicode</c> to your global USE flags in
404 <path>/etc/make.conf</path>, and then to remerge <c>sys-libs/ncurses</c> and
405 also <c>sys-libs/slang</c> if appropriate:
406 </p>
407
408 <pre caption="Emerging ncurses and slang">
409 <comment>(We avoid putting these libraries in our world file with --oneshot)</comment>
410 # <i>emerge --oneshot --verbose --ask sys-libs/ncurses sys-libs/slang</i>
411 </pre>
412
413 <p>
414 We also need to rebuild packages that link to these, now the USE changes have
415 been applied. The tool we use (<c>revdep-rebuild</c>) is part of the
416 <c>gentoolkit</c> package.
417 </p>
418
419 <pre caption="Rebuilding of programs that link to ncurses or slang">
420 # <i>revdep-rebuild --soname libncurses.so.5</i>
421 # <i>revdep-rebuild --soname libslang.so.1</i>
422 </pre>
423
424 </body>
425 </section>
426 <section>
427 <title>KDE, GNOME and Xfce</title>
428 <body>
429
430 <p>
431 All of the major desktop environments have full Unicode support, and will
432 require no further setup than what has already been covered in this guide. This
433 is because the underlying graphical toolkits (Qt or GTK+2) are UTF-8 aware.
434 Subsequently, all applications running on top of these toolkits should be
435 UTF-8-aware out of the box.
436 </p>
437
438 <p>
439 The exceptions to this rule come in Xlib and GTK+1. GTK+1 requires a
440 iso-10646-1 FontSpec in the ~/.gtkrc, for example
441 <c>-misc-fixed-*-*-*-*-*-*-*-*-*-*-iso10646-1</c>. Also, applications using
442 Xlib or Xaw will need to be given a similar FontSpec, otherwise they will not
443 work.
444 </p>
445
446 <note>
447 If you have a version of the gnome1 control center around, use that instead.
448 Pick any iso10646-1 font from there.
449 </note>
450
451 <pre caption="Example ~/.gtkrc (for GTK+1) that defines a Unicode compatible font">
452 style "user-font"
453 {
454 fontset="-misc-fixed-*-*-*-*-*-*-*-*-*-*-iso10646-1"
455 }
456 widget_class "*" style "user-font"
457 </pre>
458
459 <p>
460 If an application has support for both a Qt and GTK+2 GUI, the GTK+2 GUI will
461 generally give better results with Unicode.
462 </p>
463
464 </body>
465 </section>
466 <section>
467 <title>X11 and Fonts</title>
468 <body>
469
470 <impo>
471 <c>x11-base/xorg-x11</c> has far better support for Unicode than XFree86
472 and is <e>highly</e> recommended.
473 </impo>
474
475 <p>
476 TrueType fonts have support for Unicode, and most of the fonts that ship with
477 Xorg have impressive character support, although, obviously, not every single
478 glyph available in Unicode has been created for that font. To build fonts
479 (including the Bitstream Vera set) with support for East Asian letters with X,
480 make sure you have the <c>cjk</c> USE flag set. Many other applications utilise
481 this flag, so it may be worthwhile to add it as a permanent USE flag.
482 </p>
483
484 <p>
485 Also, several font packages in Portage are Unicode aware.
486 </p>
487
488 <pre caption="Optional: Install some more Unicode-aware fonts">
489 # <i>emerge terminus-font intlfonts freefonts cronyx-fonts corefonts</i>
490 </pre>
491
492 </body>
493 </section>
494 <section>
495 <title>Window Managers and Terminal Emulators</title>
496 <body>
497
498 <p>
499 Window managers not built on GTK or Qt generally have very good Unicode
500 support, as they often use the Xft library for handling fonts. If your window
501 manager does not use Xft for fonts, you can still use the FontSpec mentioned in
502 the previous section as a Unicode font.
503 </p>
504
505 <p>
506 Terminal emulators that use Xft and support Unicode are harder to come by.
507 Aside from Konsole and gnome-terminal, the best options in Portage are
508 <c>x11-terms/rxvt-unicode</c>, <c>xfce-extra/terminal</c>,
509 <c>gnustep-apps/terminal</c>, <c>x11-terms/mlterm</c>, <c>x11-terms/mrxvt</c> or
510 plain <c>x11-terms/xterm</c> when built with the <c>unicode</c> USE flag and
511 invoked as <c>uxterm</c>. <c>app-misc/screen</c> supports UTF-8 too, when
512 invoked as <c>screen -u</c> or the following is put into the
513 <path>~/.screenrc</path>:
514 </p>
515
516 <pre caption="~/.screenrc for UTF-8">
517 defutf8 on
518 </pre>
519
520 </body>
521 </section>
522 <section>
523 <title>Vim, Emacs, Xemacs and Nano</title>
524 <body>
525
526 <p>
527 Vim, Emacs and Xemacs provide full UTF-8 support, and also have builtin
528 detection of UTF-8 files. For further information in Vim, use <c>:help
529 mbyte.txt</c>.
530 </p>
531
532 <p>
533 Nano currently does not provide support for UTF-8, although it has been planned
534 for a long time. With luck, this will change in future. At the time of writing,
535 UTF-8 support is in Nano's CVS, and should be included in the next release.
536 </p>
537
538 </body>
539 </section>
540 <section>
541 <title>Shells</title>
542 <body>
543
544 <p>
545 Currently, <c>bash</c> provides full Unicode support through the GNU readline
546 library. Z Shell users are in a somewhat worse position -- no parts of the
547 shell have Unicode support, although there is a concerted effort to add
548 multibyte character set support underway at the moment.
549 </p>
550
551 <p>
552 The C shell, <c>tcsh</c> and <c>ksh</c> do not provide UTF-8 support at all.
553 </p>
554
555 </body>
556 </section>
557 <section>
558 <title>Irssi</title>
559 <body>
560
561 <p>
562 Since 0.8.10, Irssi has complete UTF-8 support, although it does require a user
563 to set an option.
564 </p>
565
566 <pre caption="Enabling UTF-8 in Irssi">
567 /set term_charset UTF-8
568 </pre>
569
570 <p>
571 For channels where non-ASCII characters are often exchanged in non-UTF-8
572 charsets, the <c>/recode</c> command may be used to convert the characters.
573 Type <c>/help recode</c> for more information.
574 </p>
575
576 </body>
577 </section>
578 <section>
579 <title>Mutt</title>
580 <body>
581
582 <p>
583 The Mutt mail user agent has very good Unicode support. To use UTF-8 with Mutt,
584 put the following in your <path>~/.muttrc</path>:
585 </p>
586
587 <pre caption="~/.muttrc for UTF-8">
588 set send_charset="utf8" <comment>(outgoing character set)</comment>
589 set charset="utf8" <comment>(display character set)</comment>
590 </pre>
591
592 <note>
593 You may still see '?' in mail you read with Mutt. This is a result of people
594 using a mail client which does not indicate the used charset. You can't do much
595 about this than to ask them to configure their client correctly.
596 </note>
597
598 <p>
599 Further information is available from the <uri
600 link="http://wiki.mutt.org/index.cgi?MuttFaq/Charset"> Mutt WikiWiki</uri>.
601 </p>
602
603 </body>
604 </section>
605 <section>
606 <title>Less</title>
607 <body>
608
609 <p>
610 We all use a lot of <c>more</c> or <c>less</c> along with the <c>|</c> to be
611 able to correctly see the output of a command, like for example
612 <c>dmesg | less</c>. While <c>more</c> only needs the shell to be UTF-8 aware,
613 <c>less</c> needs an environment variable set, <c>LESSCHARSET</c> to ensure
614 that unicode characters are rendered correctly. This can be set in
615 <path>/etc/profile</path> or <path>~/.bash_profile</path>. Fire up the editor
616 of your choice and the add the following line to one of the files mentioned
617 above.
618 </p>
619
620 <pre caption="Setting up the Environment variable for less">
621 LESSCHARSET=utf-8
622 </pre>
623
624 </body>
625 </section>
626 <section>
627 <title>Man</title>
628 <body>
629
630 <p>
631 Man pages are an integral part of any Linux machine. To ensure that any
632 unicode in your man pages render correctly, edit <path>/etc/man.conf</path>
633 and replace a line as shown below.
634 </p>
635
636 <pre caption="man.conf changes for Unicode support">
637 <comment>(This is the old line)</comment>
638 NROFF /usr/bin/nroff -Tascii -c -mandoc
639 <comment>(Replace the one above with this)</comment>
640 NROFF /usr/bin/nroff -mandoc -c
641 </pre>
642
643 </body>
644 </section>
645 <section>
646 <title>Testing it all out</title>
647 <body>
648
649 <p>
650 There are numerous UTF-8 test websites around. <c>net-www/w3m</c>,
651 <c>net-www/links</c>, <c>net-www/elinks</c>, <c>net-www/lynx</c> and all
652 Mozilla based browsers (including Firefox) support UTF-8. Konqueror and Opera
653 have full UTF-8 support too.
654 </p>
655
656 <p>
657 When using one of the text-only web browsers, make absolutely sure you are
658 using a Unicode-aware terminal.
659 </p>
660
661 <p>
662 If you see certain characters displayed as boxes with letters or numbers
663 inside, this means that your font does not have a character for the symbol or
664 glyph that the UTF-8 wants. Instead, it displays a box with the hex code of the
665 UTF-8 symbol.
666 </p>
667
668 <ul>
669 <li>
670 <uri link="http://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html">A W3C
671 UTF-8 Test Page</uri>
672 </li>
673 <li>
674 <uri link="http://titus.uni-frankfurt.de/indexe.htm?/unicode/unitest.htm">
675 A UTF-8 test page provided by the University of Frankfurt</uri>
676 </li>
677 </ul>
678
679 </body>
680 </section>
681 <section>
682 <title>Input Methods</title>
683 <body>
684
685 <p>
686 <e>Dead keys</e> may be used to input characters in X that are not included on
687 your keyboard. These work by pressing your right Alt key (or in some countries,
688 AltGr) and an optional key from the non-alphabetical section of the keyboard to
689 the left of the return key at once, releasing them, and then pressing a letter.
690 The dead key should modify it. Input can be further modified by using the Shift
691 key at the same time as pressing the AltGr and modifier.
692 </p>
693
694 <p>
695 To enable dead keys in X, you need a layout that supports it. Most European
696 layouts already have dead keys with the default variant. However, this is not
697 true of North American layouts. Although there is a degree of inconsistency
698 between layouts, the easiest solution seems to be to use a layout in the form
699 "en_US" rather than "us", for example. The layout is set in
700 <path>/etc/X11/xorg.conf</path> like so:
701 </p>
702
703 <pre caption="/etc/X11/xorg.conf snippet">
704 Section "InputDevice"
705 Identifier "Keyboard0"
706 Driver "kbd"
707 Option "XkbLayout" "en_US" <comment># Rather than just "us"</comment>
708 <comment>(Other Xkb options here)</comment>
709 EndSection
710 </pre>
711
712 <note>
713 The preceding change only needs to be applied if you are using a North American
714 layout, or another layout where dead keys do not seem to be working. European
715 users should have working dead keys as is.
716 </note>
717
718 <p>
719 This change will come into effect when your X server is restarted. To apply the
720 change now, use the <c>setxkbmap</c> tool, for example, <c>setxkbmap en_US</c>.
721 </p>
722
723 <p>
724 It is probably easiest to describe dead keys with examples. Although the
725 results are locale dependent, the concepts should remain the same regardless of
726 locale. The examples contain UTF-8, so to view them you need to either tell
727 your browser to view the page as UTF-8, or have a UTF-8 locale already
728 configured.
729 </p>
730
731 <p>
732 When I press AltGr and [ at once, release them, and then press a, 'ä' is
733 produced. When I press AltGr and [ at once, and then press e, 'ë' is produced.
734 When I press AltGr and ; at once, 'á' is produced, and when I press AltGr and ;
735 at once, release them, and then press e, 'é' is produced.
736 </p>
737
738 <p>
739 By pressing AltGr, Shift and [ at once, releasing them, and then pressing a, a
740 Scandinavian 'å' is produced. Similarly, when I press AltGr, Shift and [ at
741 once, release <e>only</e> the [, and then press it again, '˚' is produced.
742 Although it looks like one, this (U+02DA) is not the same as a degree symbol
743 (U+00B0). This works for other accents produced by dead keys — AltGr and [,
744 releasing only the [, then pressing it again makes '¨'.
745 </p>
746
747 <p>
748 AltGr can be used with alphabetical keys alone. For example, AltGr and m, a
749 Greek lower-case letter mu is produced: 'µ'. AltGr and s produce a
750 scharfes s or esszet: 'ß'. As many European users would expect (because
751 it is marked on their keyboard), AltGr and 4 produces a Euro sign, '€'.
752 </p>
753
754 </body>
755 </section>
756 <section>
757 <title>Resources</title>
758 <body>
759
760 <ul>
761 <li>
762 <uri link="http://www.wikipedia.com/wiki/Unicode">The Wikipedia entry for
763 Unicode</uri>
764 </li>
765 <li>
766 <uri link="http://www.wikipedia.com/wiki/UTF-8">The Wikipedia entry for
767 UTF-8</uri>
768 </li>
769 <li><uri link="http://www.unicode.org">Unicode.org</uri></li>
770 <li><uri link="http://www.utf-8.com">UTF-8.com</uri></li>
771 <li><uri link="http://www.ietf.org/rfc/rfc3629.txt">RFC 3629</uri></li>
772 <li><uri link="http://www.ietf.org/rfc/rfc2277.txt">RFC 2277</uri></li>
773 <li>
774 <uri
775 link="http://www.tbray.org/ongoing/When/200x/2003/04/26/UTF">Characters vs.
776 Bytes</uri>
777 </li>
778 </ul>
779
780 </body>
781 </section>
782 </chapter>
783 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20