UTF-8/fr

UTF-8 est un encodage des caractères de longueur variable qui, dans ce cas, signifie qu'il utilise 1 à 4 octets par symbole. Le premier octet sert à encoder les caractères ASCII, donnant ainsi au jeu de caractères une totale compatibilité avec ASCII. UTF-8 signifie que les caractères ASCII et latins sont interchangeables moyennant un petit accroissement de la taille des données, parce que seul le premier chiffre binaire est utilisé. Les utilisateurs d'alphabets de l'est asiatique, comme les japonais, à qui ont a attribué une plage plus élevée d'octets sont insatisfaits, car cela conduit à plus de 50% de redondance dans leurs données.

Qu'est-ce que l'encodage des caractères ?
Les ordinateurs ne comprennent eux-mêmes pas les textes imprimés comme les humains. Pour les ordinateurs, chaque caractère est représenté par un nombre. Traditionnellement, chaque jeu de nombres utilisé pour représenter les alphabets et les caractères (connus sous le nom de système de codage, encodage, ou jeu de caractères) était limité en taille à cause de la limitation même du matériel constituant les ordinateurs.

L'histoire de l'encodage des caractères
Le plus courant (ou du moins le plus largement accepté) des jeux de caractères est l'ASCII (American Standard Code for Information Interchange). Il est largement reconnu que l'ASCII est la norme logicielle la plus réussie jamais créée. L'ASCII moderne a été normalisé en 1986 (ANSI X3.4, RFC 20, ISO/IEC 646:1991, ECMA-6) par l'American National Standards Institute.

ASCII, a strictement parler, est encodé sur 7 chiffres binaires, ce qui signifie qu'il utilise des motifs de chiffres représentables avec 7 chiffres binaires. Ce qui correspond à la plage 0 à 127 en décimal. Ceci inclut 32 caractères de contrôle non visualisables, en majorité entre 0 et 31, auxquels s'ajoute le caractère de contrôle final, DEL ou delete, dont la représentation est 127. Tous les caractères entre 32 et 126 inclus, sont visualisables : l'espace, les marques de ponctuation, les lettres latines et les chiffres.

Le huitième bit en ASCII était à l'origine utilisé comme bit de parité pour la détection d'erreurs. Si la détection d'erreurs n'est pas souhaitée, on peut le laisser à 0. Ceci signifie que, avec l'ASCII, chaque caractère est représenté par un seul octet.

Bien que l'ASCII soit suffisant pour communiquer en anglais moderne, dans d'autres langues européenes qui comprennent des caractères accentués, les choses ne sont pas aussi simples. Les normes ISO 8859 ont été développées pour satisfaire ces besoins. Elles sont rétro-compatibles avec l'ASCII, mais au lieu de laisser le huitième chiffre binaire à 0, elles l'utilisent pour former un autre ensemble de 127 caractères dans chacun des encodages. Les limitations des normes ISO 8859 sont apparues très vite, et il y a aujourd'hui 15 variantes de la norme ISO 8859 (8859-1 à 8859-15). En dehors de la plage compatible avec l'ASCII, il y a souvent des conflits entre les lettres représentées par chacun des octets. Pour compliquer encore l'interopérabilité entre versions, Windows-1252 est utilisée à leur place dans certaines versions de Microsoft Windows pour les langues européennes. Il s'agit d'un jeu étendu de ISO-8859-1, cependant il en diffère de plusieurs façons. Tous ces jeux restent néanmoins compatibles avec ASCII.

The necessary development of completely different single-byte encodings for non-Latin alphabets, such as EUC (Extended Unix Coding) which is used for Japanese and Korean (and to a lesser extent Chinese) created more confusion. Other operating systems still used different character sets for the same languages, for example, Shift-JIS and ISO-2022-JP. Users wishing to view cyrillic glyphs had to choose between KOI8-R for Russian and Bulgarian or KOI8-U for Ukrainian, as well as all the other cyrillic encodings such as the unsuccessful ISO 8859-5, and the common Windows-1251 set. All of these character sets broke most compatibility with ASCII. Although it should be mentioned KOI8 encodings place cyrillic characters in Latin order, so in case the eighth bit is stripped, text is still decipherable on an ASCII terminal through case-reversed transliteration.

Tout cela conduisait à la confusion générale, et à une presque totale incapacité à communiquer dans plusieurs langues; en particulier à travers des alphabets différents. C'est là qu'Unicode entre en scène.

Qu'est-ce qu'Unicode ?
La norme Unicode jette aux orties la limite traditionnelle d'un octet pour les jeux de caractères. Elle utilise 17 plans de 65 536 points de code pour décrire un maximum de 1 114 112 caractères. Comme le premier plan, aussi connu sous le nom de Basic Multilingual Plane (Plan Multilingue de Base) ou BMP, contient presque tous les caractères dont un utilisateur aura jamais besoin, beaucoup ont fait la supposition fausse que l'Unicode était un jeu de caractères encodé sur 16 chiffres binaires.

Unicode has been mapped in many different ways, but the two most common are UTF (Unicode Transformation Format) and UCS (Universal Character Set). A number after UTF indicates the number of bits in one unit, while the number after UCS indicates the number of bytes. UTF-8 has become the most widespread means for the interchange of Unicode text as a result of its eight-bit clean nature; it is therefore the subject of this document.

What UTF-8 can do
UTF-8 allows users to work in a standards-compliant and internationally accepted multilingual environment, with a comparatively low data redundancy. It is the preferred way for transmitting non-ASCII characters over the Internet, through Email, IRC, or almost any other medium. Despite this, many people regard UTF-8 in online communication as abusive. It is always best to be aware of the attitude towards UTF-8 in a specific channel, mailing list, or Usenet group before using non-ASCII UTF-8.

Finding or creating UTF-8 locales
Now that the principles behind Unicode have been laid out, get ready to start using UTF-8 locally!

For users interested in more knowledge further explanation can be found in the Gentoo Localization Guide.

Next, the user needs to decide whether a UTF-8 locale is available for the language of choice, or whether one needs to be generated.

From the output of the above command, look for a result with a suffix similar to. If there is no result with a similar suffix a UTF-8 compatible locale must be created.

Replace "en_GB" with the desired locale setting:

Another way to include a UTF-8 locale is to add it to the file and generate necessary locales using the  command. Locales will be written to the locale-archive.

Setting the locale
There is one environment variable that needs to be set in order to use the new UTF-8 locales: LC_CTYPE (optionally modify the LANG variable to change the system language as well). There are also many different ways to set it; some system administrators prefer to only have a UTF-8 environment for a specific user, in which case they set them in their ( for Bourne shell users),  or  ( for Bourne again shell users). More details and best practices can be found in the Localization Guide.

Still others prefer to set the locale globally. One specific circumstance where the author particularly recommends doing this is when is in use, because this init script starts the display manager and desktop before any of the aforementioned shell startup files are sourced. In other words, this is performed before any of the variables are loaded in the environment.

Setting the locale globally should be done using file. This file should look something like the following:

Next, the environment must be updated by running the following command:

Now, run with no arguments to see if the correct variables have been loaded in the environment:

Alternatively, using eselect to set locales
Although it is good to maintain the system as described above, it is possible to verify the correct locale configured using the utility.

Use to list the available locales on the system:

Using setting the locale is as simple as listing them. Once the correct locale has been determined invoke:

Check the result:

In case it is preferred to have with   instead of , run the appropriate  command:

Running the following command will update the variables in the shell:

That is everything. The system is now using UTF-8 locales. The next hurdle is the configuration of the applications used from day to day.

Application support
When Unicode first started gaining momentum in the software world, multibyte character sets were not well suited to languages like C, which is the base language of most commonly used programs. Even today, some programs are not able to handle UTF-8 properly. Fortunately the majority of programs, especially the common ones, are supported.

Noms de fichiers, NTFS, et FAT
There are several NLS options in the Linux kernel configuration menu, but it is important to not become confused. For the most part, the only thing that needs to be done is to build UTF-8 NLS support into the kernel, and change the default NLS option to utf8.

When planning to mount NTFS partitions, users may need to specify a  option with mount. When planning on mounting FAT partitions, users may need to specify a  option with mount. Optionally, users can also set a default codepage for FAT in the kernel configuration.

Avoid setting  to UTF-8; it is not recommended. Instead, pass the  option when mounting FAT partitions. For further information or see the appropriate kernel documentation at

For changing the encoding of filenames, can be used.

The format of the command is as follows:

Substitute iso-8859-1 with the charset being converted from:

For changing the contents of files, use the utility, it comes bundled with  and should be installed on all Gentoo systems. Substitute iso-8859-1 with the charset being converted from. After running the command be sure to check for sane output:

To convert a file, another file must be created:

The recode package can also be used for this purpose.

The system console
To enable UTF-8 on the console edit. Set  and read the comments -- it is important to have a font that has a good range of characters to make the most of Unicode. For this to work make sure the Unicode locale has been properly created.

The keymap variable, set in, should have a Unicode keymap specified.

Ncurses et Slang
It is wise to add to the global USE flags in, and then to re-emerge  and. Portage will do this automatically if the  or   options are used. Run the following command to pull in the packages:

We also need to rebuild packages that link to these, now the USE changes have been applied. The tool we use is part of the  package.

KDE, GNOME, and Xfce
Tous les environnements de bureau majeurs prennent totalement en charge l'Unicode, et ne nécessitent pas d'autres étapes de configuration que celles décrites dans ce guide. Ceci est dû au fait que les boîtes à outils graphiques sous-jacentes (Qt ou GTK+2) sont prédisposées UTF-8 et que, par conséquent, les applications qui s'appuient sur ces boîtes à outils le sont également dès l'installation.

Les exceptions à cette règle surviennent avec Xlib et GTK+1. GTK+1 requiert une spécification de police de caractères iso-10646-1 dans ~/.gtkrc, par exemple,. C'est pourquoi, les applications utilisant Xlib ou Xaw doivent recevoir une spécification de police de caractères similaire ; autrement elles ne fonctionnent pas.

Dans les applications qui prennent en charge les interfaces graphiques Qt et GTK+2, l'interface GTK+2 donnera en général de meilleurs résultats avec Unicode.

X11 and fonts
TrueType fonts have support for Unicode, and most of the fonts that ship with Xorg have extensive character support, although, obviously, not every single glyph available in Unicode has been created for that font.

Also, many font packages in Portage are Unicode aware. See the Fontconfig page for more information on recommended fonts and configuration.

Window managers and terminal emulators
Window managers not built on GTK+ or Qt generally have very good Unicode support, as they often use the Xft library for handling fonts. If the window manager does not use Xft for fonts, then it is still possible to use the FontSpec mentioned in the previous section as a Unicode font.

Terminal emulators that use Xft and support Unicode are harder to come by. Aside from Konsole and gnome-terminal, the best options in Portage are, , , , or plain when built with the   USE flag and invoked as. supports UTF-8 too, when invoked as or the following is put into the :

Vim, emacs, xemacs, and nano
Vim provides full UTF-8 support, and also has builtin detection of UTF-8 files. For further information in Vim, use.

GNU Emacs depuis la version 23 et XEmacs version 21.5 prennent totalement en charge l'UTF-8. GNU Emacs 24 prend aussi en charge l'édition de textes bidirectionnels.

Nano fournit une prise en charge totale de l'UTF-8 depuis la version 1.3.6.

Shells
Currently, provides full Unicode support through the GNU readline library. Z Shell offers Unicode support with the   USE flag.

The C shell, and  do not provide UTF-8 support at all.

Irssi
Irssi dispose d'une prise en charge totale de l'UTF-8, bien que cela nécessite la définition d'une option par l'utilisateur.

For channels where non-ASCII characters are often exchanged in non-UTF-8 charsets, the command may be used to convert the characters. Type for more information.

Mutt
The Mutt mail user agent has very good Unicode support. To use UTF-8 with Mutt, nothing needs to be put in the configuration files. Mutt will work under Unicode environment without modification if all the configuration files (signature included) are UTF-8 encoded.

Une information complémentaire est disponible sur Mutt Wiki.

Man
Man pages are an integral part of any Linux machine. To ensure that any unicode in the man pages render correctly, edit and replace a line as shown below. This is only needed when is used instead of.

links and elinks
These are commonly used text-based browsers, and we shall see how we can enable UTF-8 support on them. On and, there are two ways to go about this, one using the Setup option from within the browser or editing the config file. To set the option through the browser, open a site with or  and then + to enter the Setup Menu then select Terminal options, or press. Scroll down and select the last option  by pressing. Then Save and exit the menu. On one may have to do a repeat + and then press  to save. The config file option, is shown below.

Samba
Samba est une suite logicielle qui met en œuvre le protocole SMB (Server Message Block) pour les systèmes UNIX tels que les Macs, Linux et FreeBSD. Le protocole est aussi parfois appelé le Common Internet File System (CIFS). Samba inclut aussi le système NetBIOS - utilisé pour le partage de fichiers à travers des réseaux windows.

Ajoutez ce qui suit sous la section [global] :

Test complet
There are numerous UTF-8 test websites around and most of the popular browsers in Gentoo have full UTF-8 support.

When using one of the text-only web browsers, make absolutely sure a Unicode-aware terminal is used.

If certain characters are displayed as boxes with letters or numbers inside, then the current font does not have glyphs for those characters. Instead, it displays a box with the hex code of the UTF-8 symbol.


 * unicode-table.com
 * A W3C UTF-8 Test Page
 * A UTF-8 test page provided by the University of Frankfurt

System configuration files (in /etc)
Most system configuration files (such as ) do not support UTF-8. It is recommended to stick with the ASCII character set for these files.

External resources

 * The Wikipedia entry for Unicode
 * The Wikipedia entry for UTF-8
 * Unicode.org
 * UTF-8.com
 * RFC 3629
 * RFC 2277
 * Characters vs. Bytes
 * The GNU C Library: Locales and Internationalization
 * Unifoundry.com - Unicode Tutorial
 * unicode USE flag description