Search code examples
javascriptnode.jsencodingasciipolish

Saving 'Ł' and 'ł' characters as ascii/ansi file with nodejs


I'm having hard time saving some polish characters like 'Ł' to a ascii file.

const fs = require('fs');
fs.writeFileSync('ascii.txt','Ł','ascii');

I would like the output file to show 'Ł' character. I tried buffers etc no luck. Can't figure out how to do this.


Solution

  • It is not possible.

    Neither characters are part of the ASCII standard.

    To save such characters to a file, you need to encode the file with a different encoding, such as UTF-8.