V
V
vsekov2019-12-25 13:23:45
Character encoding
vsekov, 2019-12-25 13:23:45

How to save a file in windows-1251 encoding?

The project uses a file entry with the extension '*.cpp', but the standard

fs.writeFile(id + '.cpp', ans, function(err) {
            if(err) throw err;
        });
writes the file in UTF-8 encoding.
The problem is that further you need to use only windows-1251 encoding, in which Cyrillic from UTF-8 takes on a frightening look: ADdxUU8eZvo.jpg
How can I write a file with windows-1251 encoding using nodejs?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
2
2CHEVSKII, 2019-12-25
@2chevskii

fs.writeFile takes as its third argument an options object that has an encoding field. I think you'll find out more.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question