1

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.

j809809jkdljfja
  • 767
  • 2
  • 9
  • 25
  • 1
    Those characters do not exist in ASCII. [See for yourself.](http://www.asciitable.com/) – Pointy Jan 25 '17 at 13:29
  • Is there some reason why it has to be specifically an ASCII file? Are you sure you know what the word means? – JJJ Jan 25 '17 at 13:32
  • I need to import it as ascii file to an external program, I would like it to contain those characters. – j809809jkdljfja Jan 25 '17 at 13:36
  • [Here](https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/) is a nice reading on the topic if you are interested – pergy Jan 25 '17 at 13:36
  • (Don't say ASCII unless you mean it.) While one of the ANSI encodings might work, such as Windows-1250, UTF-8 is much preferred for files and streams unless your external program won't read it. – Tom Blodget Jan 26 '17 at 04:18

2 Answers2

4

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.

A.Perrot
  • 323
  • 1
  • 8
1

ASCII does not have polish characters. See here: ASCII TABLE

wwn
  • 563
  • 5
  • 9