I have some issues in set encoding in node.js. I tried to set encoding to utf8 using writeFile function. But no results. current file I want to set encoding using node.js wa
By default, the fs module will write files with an encoding of 'utf8'. UTF-8 is an encoding commonly used in web pages and other documents. File encoding refers to the character set that is used for the contents of the file. Commonly used encodings are 'utf8', 'ascii', 'binary', 'hex', 'base64' and 'utf16le'.
Source from stackabuse.
To write file with encoding
If options is a string, then it specifies the encoding. Example:
fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
or is options is an object then,
fs.writeFile('message.txt', 'Hello Node.js', {encoding: 'utf8'}, callback);
Check here for more information