I'm writing a desktop application using Node-Webkit. This application opens a previously saved JSON file and then put the JSON file contents into a Javascript Object. The function works fine but when the JSON file contains a string with accents (like: á, é, í, ó, ú) it replaces those characters with symbols like "�" and "�".
Would you be so kind of help me to solve this problem, because I need to display the right characters of the strings. I will thank you for your help.
My HTML file is encoded in UTF-8, the script is stored in the HTML document.
Here is a code sample:
$("#openFile").click(function() {
fileOpened = JSON.parse(open("file.json"));
console.log(fileOpened.author);
});
function open(path, contents) {
contents = fs.readFileSync(path, {encoding:"utf8"});
return contents;
}