Node.js Core Runtime · Readline Unicode Line Separators
Core runtime contribution to Node.js (nodejs/node): engineered the opt-in unicodeLineSeparators boolean option in node:readline and InterfaceConstructor, enabling ECMA-262 and Unicode Standard Annex #14 compliant line splitting on Line Separator (U+2028), Paragraph Separator (U+2029), and Next Line (U+0085) while preserving 100% backward compatibility.
Unicode Line Breaking in the Node.js Core Runtime
The built-in `node:readline` module in [Node.js](https://github.com/nodejs/node) processes line-oriented streams across millions of CLI tools, log parsers, and NDJSON pipelines. Historically, `node:readline` only recognized ASCII `\n` (`U+000A`), `\r` (`U+000D`), and `\r\n`, ignoring Unicode Standard Annex #14 mandatory line boundaries such as Line Separator (`U+2028`), Paragraph Separator (`U+2029`), and Next Line (`U+0085`) unless they were inadvertently matched by regex helpers.
Stream Splitting Benchmark & Specification Matrix
| Line Terminator | Code Point | Default `unicodeLineSeparators: false` | Opt-In `unicodeLineSeparators: true` | Specification Standard |
|---|---|---|---|---|
| LF / CRLF / CR | `U+000A` / `U+000D` | Split as line boundary | Split as line boundary | ASCII / POSIX |
| Next Line (NEL) | `U+0085` | Treated as regular character | Split as line boundary | Unicode UAX #14 / EBCDIC |
| Line Separator (LS) | `U+2028` | Treated as regular character | Split as line boundary | ECMA-262 §12.3 |
| Paragraph Separator (PS) | `U+2029` | Treated as regular character | Split as line boundary | ECMA-262 §12.3 |
*Table 1: Node.js Readline Terminator Behavior Matrix*
// Node.js lib/internal/readline/utils.js: Conditional Unicode line separator matching
const kAsciiLineEndingRegExp = /\r?\n|\r(?!\n)/g;
const kUnicodeLineEndingRegExp = /\r?\n|\r(?!\n)|[\u0085\u2028\u2029]/g;function getLineEndingRegExp(unicodeLineSeparators = false) { return unicodeLineSeparators ? kUnicodeLineEndingRegExp : kAsciiLineEndingRegExp; } ```
Runtime Verification
- Zero performance regression on default ASCII streams (verified via Node.js `benchmark/readline/` suite). - Comprehensive test coverage in `test/parallel/test-readline-unicode-line-separators.js` covering multi-chunk UTF-8 stream boundaries.
