Unknown encoding: gb2312
发布于 3 个月前 作者 yakczh 802 次浏览 来自 问答
const fs = require('fs');
var readable = fs.createReadStream("gbk.txt", {
    encoding: 'gb2312',
    fd: null,
});
readable.on('readable', function() {
  var chunk;
  while (null !== (chunk = readable.read(1))) {
    console.log(chunk); // chunk is one char
  }
});

internal/fs.js:20 throw new Error(Unknown encoding: ${encoding}) ^

Error: Unknown encoding: gb2312 at assertEncoding (internal/fs.js:20:11) at getOptions (fs.js:58:5) at new ReadStream (fs.js:1824:24) at Object.fs.createReadStream (fs.js:1813:10) 如果要读gbk编码的文件,还有什么方法

回到顶部