How to set file encoding in Node.js -


i have issues in set encoding in node.js. tried set encoding utf8 using writefile function. no results. current file want set encoding using node.js encoded in unicode.

by default, fs module write files encoding of 'utf8'. utf-8 encoding commonly used in web pages , other documents. file encoding refers character set used contents of file. commonly used encodings 'utf8', 'ascii', 'binary', 'hex', 'base64' , 'utf16le'.

source stackabuse.

to write file encoding

if options string, specifies encoding. example:

fs.writefile('message.txt', 'hello node.js', 'utf8', callback); 

or options object then,

fs.writefile('message.txt', 'hello node.js', {encoding: 'utf8'}, callback); 

check here more information


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

minify - Minimizing css files -

php - How to remove letter in front of the word laravel -