Skip to main content
Version: v0.0.2

Function: escapeRelease()

escapeRelease(value, delimiters): string

Apply X12 release-character escapes to a value so it can be emitted inside a segment without ambiguity. Every occurrence of the four delimiters (or the release character itself) is preceded by ?; other bytes pass through verbatim. The companion to unescapeRelease.

Parameters

value

string

delimiters

Delimiters

Returns

string

Example

import { escapeRelease } from "@cosyte/x12";
const d = { element: "*", repetition: "^", component: ":", segment: "~" };
escapeRelease("ab~cd*ef:gh", d); // "ab?~cd?*ef?:gh"
escapeRelease("a?b", d); // "a??b"