Node’s fs module, readable stream can’t read Chinese data, ask for advice

  node.js, question

The code is as follows:

var fs = require('fs');
 var readableStream = fs.createReadStream('mouse.txt');
 var data = '';
 
 readableStream.setEncoding('utf8');
 
 readableStream.on('data', function(chunk) {
 Dataplus =chunk;
 });
 
 readableStream.on('end', function() {
 console.log(data);
 });

The data in mouse.txt is “microblog that wants to eat seafood.”

The output is as follows:
图片描述

Look, it’s blank. What the hell is going on?

In order to confirm that it is not your terminal display problem, try to see if the following code has written the datattt.jsinside

var fs = require('fs');
 var readableStream = fs.createReadStream('app.js');
 readableStream.setEncoding('utf8');
 
 var writableStream = fs.createWriteStream('tttt.js', {
 defaultEncoding: 'utf-8'
 });
 
 readableStream.pipe(writableStream);