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

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -