The diplomas that arrived with strange letters

The day before graduation, a Spanish secondary school received the students’ diplomas from the printer. On several of them, the names had strange letters: “Begoña Núñez” or “José Ruiz”.

The school office insisted that every name was spelt correctly in its application, and the printer said it had printed exactly the CSV file it was sent. Names without accents or ñ, such as “Marta Gil”, had come out perfectly.

The computing teacher opened that same CSV in his code editor and every name looked fine.

What had happened to the names?

How to solve the cases
Graduation diploma with a student’s name written with strange letters, next to a mortarboard

Hints

Reveal them one at a time, only when you need them.

Solution

The file was fine, but the printer opened it with a different encoding from the one used to save it. The school office saved it in UTF-8, which writes “ñ” and accented vowels with two numbers, and the printer’s computer displayed each of those numbers as a separate letter.

What happened?

A computer does not store letters but numbers. The encoding is the table that says which letter each number stands for. Letters of the English alphabet have the same number in the most common tables, which is why “Marta Gil” came out fine. “Ñ” and accented vowels, on the other hand, change from one table to another. This is what happened:

  1. The school’s application saved “Begoña” in UTF-8, which writes “ñ” with two numbers: C3 and B1.
  2. At the printer, they double-clicked the CSV to open it in Excel, which read it with another table, Windows-1252, where each number is one letter.
  3. In that table, C3 is “Ô and B1 is “±”. That is why “ñ” became “ñ”, and “Begoña”, “Begoña”.
  4. The teacher’s editor opened the file in UTF-8, the same table it was saved with, which is why the names looked fine there.

Nobody had misspelt the names: the mistake was in the table used to read them.

How could it be fixed and prevented?

To fix it, the printer needed to open the original file specifying that it is in UTF-8. In Excel, this is done from Data > Get Data > From File > From Text/CSV, choosing UTF-8 as the file origin. If someone had already saved the CSV with the strange symbols, they had to ask the school office for another copy.

To stop it from happening again, these measures helped:

  • Export as UTF-8 with BOM, a mark at the start of the file that indicates its encoding. According to Microsoft, Excel then opens it correctly.
  • Do not double-click CSV files; import them specifying their encoding instead.
  • Check a proof before printing, looking for symbols such as “Ô.

Further reading

What a character encoding is and what happens when the wrong one is used is explained in Character encodings for beginners — W3C.

How UTF-8 encodes each character is defined in the standard RFC 3629: UTF-8, a transformation format of ISO 10646 — IETF.

The letter for each number in Windows-1252 can be looked up in the cp1252 to Unicode table — Unicode Consortium.

To open a UTF-8 CSV in Excel, see Opening CSV UTF-8 files correctly in Excel — Microsoft Support.

Have a story worth investigating?

Suggest a case

A project by Eniun

How do you solve the cases?

Each case presents a mystery that seems to defy explanation.

A moderator who knows the solution reads the mystery to the group. The group works out what happened by asking questions, discussing hypotheses and using what they know.

You can project the case on a screen so everyone can read it and refer back to it during the discussion.

The moderator can guide the discussion without giving away the answer. If the group gets stuck, each case offers three graded hints under “Hints”, which can be revealed one at a time.

Once the moderator confirms that the group has found the answer, select “Show answer” to open the solution.

You can also solve the cases on your own: read the story, try to come up with an explanation and use the hints only when you need them.