Search code examples
node.jsfilestream

node.js filestream to read international characterset(French and German)


In my node.js I read characters from French and German language. As you know some characters doesn't exist in English. So, please help me to read the characters using node.js filestream.

fs.createReadStream(sFile,{ encoding: 'latin1' })
tried encoding with  'binary','utf8' nothing works!

I want the below string in french to be printed as it is

Au programme 2019 : plénière composée de témoignages


Solution

  • UTF-8 works fine with accentuated characters. The problem is most likely from the file itself.

    If your file (sFile) is not encoded in UTF-8, you will not get UTF-8 encoded characters.

    Most editors (Notepad++, VSCode, etc...) have a feature that lets you convert a file to various charsets.