Open bash0312 opened 7 years ago
Are you passing undefined
to utf8.decode()
? If not, how can I reproduce this issue?
I also encountered this error and was at first a bit confused, but then realised that it was happening because I was passing a Buffer
instead of a "binary string". Maybe the docs can be made more explicit about the fact that Buffer
are actually not supported at least not until https://github.com/mathiasbynens/utf8.js/issues/7 is solved.
Reading the file with encoding set fixes this problem:
const input = fs.readFileSync('./thefile.txt', {encoding: 'utf8'});
Reading the file with encoding set fixes this problem: const input = fs.readFileSync('./thefile.txt', {encoding: 'utf8'});
If you are reading the file in that way, then you do not need this library.
node v7.0.0