Function: unescape()
unescape(
input,enc,emit,position):string
Expand HL7 escape sequences (\F\, \S, \T\, \R, \E\, \.br,
\X..\, vendor-specific \Z..) inside a field, component, or
subcomponent string. The escape delimiter comes from enc.escape (default
``), so senders using a non-default escape character are handled
transparently.
Unknown or malformed sequences are preserved VERBATIM in the output and
emit an UNKNOWN_ESCAPE_SEQUENCE warning via emit. Unterminated escapes
(an escape character with no closing partner before end-of-input) are also
preserved in full and warn once: the scan is strictly O(n) and cannot
infinite-loop on malformed input.
Parameters
input
string
enc
emit
(w) => void
position
Returns
string
Example
import { unescape, DEFAULT_ENCODING_CHARACTERS } from "@cosyte/hl7";
const warnings: Array<unknown> = [];
const out = unescape(
"patient\\F\\name\\.br\\DOB",
DEFAULT_ENCODING_CHARACTERS,
(w) => warnings.push(w),
{ segmentIndex: 1, fieldIndex: 5 },
);
// out === "patient|name\nDOB"