nodejs/node

readline: processing \u2028 and \u2029

Open

#22,448 建立於 2018年8月21日

在 GitHub 查看
 (7 留言) (1 反應) (0 負責人)JavaScript (35,535 fork)batch import
help wantedreadline

倉庫指標

Star
 (117,218 star)
PR 合併指標
 (平均合併 18天 17小時) (30 天內合併 219 個 PR)

描述

Not sure if we should fix, document, or ignore this and if it has been discussed, so to be on the safe side.

Currently, \u2028 and \u2029 are considered as line breaks by JavaScript RegExps, while they are ignored by the readline:

'use strict';

const fs = require('fs');
const readline = require('readline');

const str = '123\n456\r123\u{2028}456\u{2029}789';

console.log(str.split(/^/mu));

fs.writeFileSync('readline-test.txt', str, 'utf8');

const rl = readline.createInterface({
  input: fs.createReadStream('readline-test.txt', 'utf8'),
  crlfDelay: Infinity,
});

rl.on('line', console.log);

out

Feel free to close if this is a wontfix.

貢獻者指南