Question: Special Characters in HL7 v2
Dec 14, 2012Question: Can Hl7 v2 messages contain any special characters in them?
Answer:
A standard v2 message is restricted to ASCII characters in the range 32 to 126. Some of the characters need to be use for syntactical separators, and so there is special support for escape sequences to represent these actual characters in the message. But these sequences don’t support special characters.
To support special characters, you can do one of two things:
- Use a unicode message (i.e. UTF-16). Note that using unicode can only be done by trading partner agreement, and not many systems support unicode (mostly they are still ASCII back ends, though unicode support is wider in Europe and Asia than in primarily english speaking countries, where systems are migrating to unicode very slowly)
- Use a character escape sequence - \M or \C. These are even less supported, and not well understood (see chapter 2 of the v2 standard)
Alternatively, you can just pretend that a code page agreement has been made, and use ascii characters in the range 127 - 254. This is infrastructurally easy, but hard to manage - code pages are poorly understood, often unmanaged, and translation between them is often impossible. (Naturally, then, this is what I see most often in practice)