Skip to main content
Version: v0.0.2

Function: unescapeRelease()

unescapeRelease(input, delimiters, emit, position): string

Reverse a single X12 release-character escape sequence. Consumes ? plus its target byte when the target is one of the four detected delimiters or another ?; preserves the ? verbatim when the target is anything else (Postel's-Law tolerance - the spec leaves the ?A case ambiguous and preserving the bytes is the most defensible behavior).

Emits a single Tier-2 X12_DANGLING_RELEASE_CHAR warning when the input ends with a bare ? (no target byte to escape) - the bytes are preserved verbatim so round-trip is still byte-exact.

Parameters

input

string

delimiters

Delimiters

emit

(w) => void

position

X12Position

Returns

string

Example

import { unescapeRelease } from "@cosyte/x12";
const d = { element: "*", repetition: "^", component: ":", segment: "~" };
unescapeRelease("a?~b", d, () => {}, { segmentIndex: 0 }); // "a~b"
unescapeRelease("a??b", d, () => {}, { segmentIndex: 0 }); // "a?b"
unescapeRelease("a?Xb", d, () => {}, { segmentIndex: 0 }); // "a?Xb" (preserved)