Character encodingLe codage des caractères

Plain text and its lines said a file is characters and nothing else. That is true of what the file means; what it stores is bytes, and an encoding is the agreement that turns one back into the other. If the agreement is wrong, the letters come back wrong, which is why this is the problem French text hits first.

The declaration says which one

The very first line of an XML file is its declaration:

<?xml version="1.0" encoding="UTF-8"?>

encoding names the agreement the file was written under. UTF-8 covers accents, non-Latin alphabets and almost everything else, and it is what TMX, TBX and XLIFF use.Some programs, Windows ones above all, start a UTF-8 file with three invisible bytes announcing the encoding, called a byte order mark or BOM. Most tools take it in their stride, but one that does not will show it as  in front of the first character, or trip over a first line that looks perfectly normal on screen. If a file misbehaves only on its first line, this is usually why, and a text editor that offers to save “UTF-8 without BOM” is offering the fix.

When it goes wrong

An accented letter is where the trouble shows, because in UTF-8 it takes two bytes rather than one. Written as UTF-8 and read as if it were an older one-byte encoding, “é” arrives as two letters instead:

WrittenRead as UTF-8Read as a one-byte encoding
ééé
èèè
ççç

A whole file of that is the classic symptom: every accent has turned into two characters, and nothing else has moved. It means the file was written under one agreement and read under another, not that the text was damaged, so opening it again with the right encoding usually brings it back.The other direction is uglier. In a one-byte file opened as UTF-8, the accented bytes make no valid character at all, so they come back as . Save the file in that state and the original letter is gone for good.

Written alternately in EN and FR, translation partly generated in both directions. Rédigé en alternance en EN et en FR, traduction en partie générée dans les deux sens. Updated 2026-08-26

Le texte brut et ses lignes disait qu’un fichier est fait de caractères et de rien d’autre. C’est vrai de ce que le fichier signifie ; ce qu’il stocke, ce sont des octets, et le codage est la convention qui fait passer des uns aux autres. Si la convention est fausse, les lettres reviennent fausses, et c’est pourquoi le texte français rencontre ce problème avant tout autre.

La déclaration dit laquelle

La toute première ligne d’un fichier XML est sa déclaration :

<?xml version="1.0" encoding="UTF-8"?>

encoding nomme la convention selon laquelle le fichier a été écrit. UTF-8 couvre les accents, les alphabets non latins et à peu près tout le reste, et c’est ce qu’emploient TMX, TBX et XLIFF.Certains logiciels, ceux de Windows au premier chef, font commencer un fichier UTF-8 par trois octets invisibles qui annoncent le codage, ce qu’on appelle une marque d’ordre des octets, ou BOM (byte order mark). La plupart des outils s’en accommodent, mais celui qui ne le fait pas l’affiche sous la forme  devant le premier caractère, ou bute sur une première ligne qui semble pourtant normale à l’écran. Quand un fichier ne pose problème que sur sa première ligne, c’est en général cela, et un éditeur de texte qui propose d’enregistrer en « UTF-8 sans BOM » propose la solution.

Quand cela tourne mal

C’est sur les lettres accentuées que l’ennui se voit, parce qu’en UTF-8 elles occupent deux octets au lieu d’un. Écrit en UTF-8 puis relu comme s’il s’agissait d’un ancien codage à un octet, le « é » arrive sous la forme de deux lettres :

ÉcritRelu en UTF-8Relu dans un codage à un octet
ééé
èèè
ççç

Un fichier entier dans cet état, c’est le symptôme classique : chaque accent s’est transformé en deux caractères, et rien d’autre n’a bougé. Cela veut dire que le fichier a été écrit selon une convention et relu selon une autre, non que le texte a été abîmé : le rouvrir avec le bon codage le rétablit généralement.L’autre sens est plus vilain. Dans un fichier à un octet relu en UTF-8, les octets accentués ne forment aucun caractère valide : ils reviennent sous la forme de . Enregistrez le fichier dans cet état et la lettre d’origine est perdue pour de bon.

Written alternately in EN and FR, translation partly generated in both directions. Rédigé en alternance en EN et en FR, traduction en partie générée dans les deux sens. Mise à jour 2026-08-30

Sources

Sources

Spotted an error? Une erreur ?

Language, content, a broken link: tell me what you saw and I will fix it. Langue, contenu, lien brisé : dites-moi ce que vous avez vu et je corrige.

Sending opens your mail app with the report addressed to me. L'envoi ouvre votre application de courriel avec le signalement déjà adressé à moi.