I keep running in to encoding issues on windows.
var content = fs.readFileSync("file.txt", 'utf8').toString();
console.log(content)
Where file.txt was created in notepad with the text "123". The output of the above is
??1 2 3
and not "123" as I would expect. If I read on windows a text file created on a Mac, it works fine. So it is just windows created files causing me the issue.
I've hunted with web with no luck, including this post node.js readfile error with utf8 encoded file on windows
I also experimented with toString('utf8') with no luck.
Later on in code I construct a JSON string using this input, and it ends up as
??1\u00002\u00003\u0000�
Yuk.
What am I doing wrong?
Thanks Gary.