/[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.47 - (show annotations) (download) (as text)
Tue Apr 17 19:04:17 2007 UTC (7 years, 8 months ago) by nightmorph
Branch: MAIN
Changes since 1.46: +5 -6 lines
File MIME type: application/xml
updated zsh to reflect unicode support, bug 174954

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

  ViewVC Help
Powered by ViewVC 1.1.20