The message.setEndOfLine(eol) function allows you to explicitly control the end-of-line (EOL) character(s) used when processing or generating formatted messages.
This is useful when working with systems that require specific line termination formats.
Syntax
message.setEndOfLine(eol)
| Parameter | Type | Description |
|---|
eol | String | The end-of-line character(s) to use for the message |
| Value | Description |
|---|
'\r' | Carriage Return (CR) — common in HL7 |
'\n' | Line Feed (LF) — Unix/Linux format |
'\r\n' | CR + LF — Windows format |
'' | No line terminator (X12 only) |
Supported Message Types
This method applies only to the following formatted message types:
- HL7
- ASTM
- CSV
- EDIFACT
- Fixed Width (Old Fxd Width, Fxd Length)
- JSON
- X12
Behavior Notes
The EOL setting affects how the message is serialized or output, not how it is internally parsed.
For HL7 messages, the standard segment terminator is typically '\r'. Changing this may impact compatibility with downstream systems.
For X12 messages, an empty string ('') is allowed because segment terminators are defined differently (via delimiters within the ISA segment).
If an unsupported value is provided, the function may throw an error or be ignored depending on context.