The Path
Module 2 · Reading an HL7 v2 message·10 min
Character sets and accents
MSH-18, UTF-8 or ISO 8859-1: why “é” sometimes turns into “é”.
At the sleep lab, the technologist types “Nuit agitée” (restless night). Next morning, the pulmonologist reads “Nuit agitée” in the hospital record. Nobody made a typo. The sender and the receiver simply disagree on how to turn letters into bytes.
Here is the message as it should leave the lab, with its character set declared in the header. The Leleux Clinic is French-speaking, so the note is in French: that is where the accents come from.
The sleep lab sends Marie Dubois’s AHI and a French note full of accents. MSH-18 announces UTF-8.
Bytes, not letters
On the wire, an HL7 message is just a sequence of bytes. An encoding is the table that says which byte means which letter. Three encodings come up all the time:
- 7-bit ASCII: 128 characters, unaccented letters, digits, punctuation.
- ISO 8859-1 (Latin-1): 256 characters, one byte each. It adds the accented letters of Western Europe.
- UTF-8: every alphabet in the world, on one or more bytes. ASCII is part of it, byte for byte.
A fourth one, outside the HL7 standard, shows up everywhere: Windows-1252, the Windows character set for Western Europe. It copies Latin-1, but puts characters that Latin-1 lacks in the 80 to 9F range.
| Character | ISO 8859-1 | Windows-1252 | UTF-8 |
|---|---|---|---|
A |
41 |
41 |
41 |
é |
E9 |
E9 |
C3 A9 |
ë |
EB |
EB |
C3 AB |
ü |
FC |
FC |
C3 BC |
œ |
missing | 9C |
C5 93 |
€ |
missing | 80 |
E2 82 AC |
’ |
missing | 92 |
E2 80 99 |
For a plain letter, nothing changes. For an é, everything does: one byte on one side, two on the other.
MSH-18: the message states its encoding
MSH-18 says which character set the message uses. Its values come from table 0211. The ones you will meet in Europe:
MSH-18 value |
Meaning |
|---|---|
| empty | 7-bit ASCII, the default |
ASCII |
the same thing, written out |
8859/1 |
ISO 8859-1, Latin-1 |
UNICODE UTF-8 |
UTF-8 |
The code has a space in it: UNICODE UTF-8. Plain “UTF-8” is not in the table.
The field can repeat. The first value gives the default encoding of the message. Later ones announce extra character sets, and MSH-20 then says how to switch between them. With a single character set declared, MSH-20 stays empty.
In ASCII, Latin-1 and UTF-8, the delimiters |^~\& stay the same ASCII bytes. That is why an encoding problem rarely breaks the structure: it damages the text, silently.
Anatomy of an “é”
The lab software writes UTF-8: the é leaves as two bytes, C3 A9. The hospital record reads ISO 8859-1, one byte per character. It sees C3, which is Ã, then A9, which is ©. One é becomes “é”.
Sleep lab
writes UTF-8
Engine
relays
Hospital record
reads ISO 8859-1
Doctor screen
displays
- ORU^R01 · MSH-18 empty
- same bytes
- ACK · AA
- Nuit agitée
- MSH-18 = UNICODE UTF-8
- ORU^R01 · UTF-8
- Nuit agitée
Here is what the hospital record received. Click the note, then switch to edit mode and put the accents back where they belong.
The same message, decoded as ISO 8859-1 although it was written in UTF-8. MSH-18 is empty.
The other direction is worse. Text written as ISO 8859-1 and read as UTF-8 contains a lone E9 byte. In UTF-8, that is an invalid sequence. The receiver replaces it with “�”, the Unicode replacement character, or rejects the message.
Belgium: three languages in one message
In Belgium, one hospital can receive French, Dutch and, in the East, German. é, è, ç for “Liège”, ë for “België”, ü for “Bütgenbach”. All of them exist in both ISO 8859-1 and UTF-8.
But ISO 8859-1 is missing two characters: œ and the euro sign. French medical vocabulary loves œ: “œdème” (edema), “cœur” (heart). In 8859-1 they have to be converted, usually to “oe”. UTF-8 has no such problem.
Windows-1252: the fake Latin-1
Plenty of Windows software writes Windows-1252 while calling it Latin-1. For common accented letters, it makes no difference: é is E9 in both. For œ, € and the curly apostrophe ’ that Word slips in everywhere, it does. In real Latin-1, the bytes 9C, 80 and 92 are control characters, not letters. And a receiver expecting UTF-8 rejects them.
Windows-1252 has no code in table 0211. You cannot declare it in MSH-18: name it in the interface spec, or convert before sending.
The BOM: three invisible bytes
Some editors put a signature at the start of a UTF-8 file, the BOM: the bytes EF BB BF. Invisible in the editor. But read as ISO 8859-1, the file starts with “MSH”. A receiver that expects MSH from the very first byte no longer recognizes the header. State in the spec whether a BOM is allowed; the safest choice is not to send one.
What about escape sequences?
The standard defines \Xdd\ to write bytes in hexadecimal, but what they mean is left to an agreement between the two systems. It also defines \Cxxyy\ to switch character sets mid-text: \C2D41\ switches to Latin-1. These sequences exist, but a declared and honored encoding solves the problem far more simply.
What goes in the interface spec
The standard requires it: if the default encoding is not 7-bit ASCII, it must be documented in the conformance profile or the implementation agreement. In practice, write down:
- the real encoding of the bytes sent, and the exact value of
MSH-18; - what the receiver does when
MSH-18is empty or does not match; - who converts when the two sides differ (often the engine);
- the rule for the BOM;
- a test set with
é,ë,ü,œ, the euro sign and a curly apostrophe’.
And in FHIR?
The question almost disappears: in FHIR, JSON is always UTF-8. The specification requires it. An engine converting v2 to FHIR must therefore decode the v2 message with the right encoding before writing the resource.
Check your understanding
1 of 5A message arrives with MSH-18 empty. Which character set must the receiver assume?
+50 XPPass the quiz (4 correct answers) to complete the lesson.
Reviewed and checked on 28 September 2026