NodeJS Extended ASCII Support

I'm trying to read a file that contains extended ascii characters like 'á' or 'è', but NodeJS doesn't seem to recognize them.

I tried reading into:

  • Buffer
  • String

Tried differente encoding types:

  • ascii
  • base64
  • utf8

as referenced on http://nodejs.org/api/fs.html

Is there a way to make this work?

The file I was trying to read was in ANSI encoding. When I tried to read it using the 'fs' module's functions, it couldn't perform the conversion of the extended ASCII characters.

I just figured out that nodepad++ is able to actually convert from some formats to UTF-8, instead of just flagging the file with UTF-8 encoding.

After converting it, I was able to read it just fine and apply all the operations I needed to the content.

Thank you for your answers!

I use the binary type to read such files. For example

var fs = require('fs');

// this comment has I'm trying to read a file that contains extended ascii characters like 'á' or 'è',

fs.readFile("foo.js", "binary", function zz2(err, file) {  
    console.log(file);
});

When I do save the above into foo.js, then the following is shown on the output:

var fs = require('fs');

// this comment has I'm trying to read a file that contains extended ascii characters like '⟡ 漀爀 ✀',

fs.readFile("foo.js", "binary", function zz2(err, file) {  
    console.log(file);
});

The wierdness above is because I have run it in an emacs buffer.