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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.54 - (show annotations) (download) (as text)
Mon Sep 20 07:54:51 2010 UTC (5 years ago) by nightmorph
Branch: MAIN
Changes since 1.53: +7 -4 lines
File MIME type: application/xml
clean up unicode font section. there's some weirdness going on in Portage with cronyx getting masked, other alternatives recommended, and then the whole thing getting reverted. since cronyx-fonts is purely cyrillic (russian) characters, it's simpler to just remove the recommendation in favor of less limited font sets.

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

  ViewVC Help
Powered by ViewVC 1.1.20