Tuesday, 2 May 2017

How to read non-english character like: "Ä,ö" from file in node.js

When I read a JSON file in node.js the non-english character display as '?' instead of the origin character.

   var fs = require('fs');
   var path = require('path');

var stream = fs.createReadStream(path.join(__dirname,'../data.json'), 'utf8');

        stream.on('error', function (error) {
            response.status(500).send({ msg: error.message });
        })

        stream.pipe(response);
    }
}



via Sari

No comments:

Post a Comment