Function: decodeText()
decodeText(
input,enc?):string
Decode a field's escape-bearing HL7 text to its human value: the five
delimiter escapes (\F\ \S\ \T\ \R\ \E\), the truncation escape (\P),
\.br\ (→ newline), and hex (\Xdddd…) are resolved; presentational
escapes (\H\/\N, formatting, charset, vendor \Z..) are preserved
verbatim so nothing is lost. Never throws.
This is the one-call inverse of encodeText for delimiter-bearing content. It does not interpret formatting/highlight: for a normalized display string use renderText.
Parameters
input
string
the field's escape-bearing text.
enc?
EncodingCharacters = DEFAULT_ENCODING_CHARACTERS
encoding characters; defaults to the HL7 standard |^~\&.
Returns
string
the decoded value string.
Example
import { decodeText } from "@cosyte/hl7";
decodeText("Doe\\S\\John"); // "Doe^John": \S\ → component separator
decodeText("line1\\.br\\line2"); // "line1\nline2"