Hi, I’m trying to write with storage
:
function write(){
data = {"åäö":"åäö"};
data = JSON.stringify(data);
Storage.write("test.txt", data);
}
...
function read(){
Storage.read("test.txt").then(function(content) { console.log(content); // {"åäö":"å
});
}
write();
// next time app start user read();
It will output {"åäö":"å
and NOT {"åäö":"åäö"}
Anyone have an idea?
Those methods are async. So you are reading the file before it is done writing. You could either rewrite your code to run synchronous:
Storage.writeSync("test.txt", data);
Or you could read the file after the write completes like this:
Storage.write("test.txt", data).then(function(wasSuccess) {
if(wasSuccess) {
Storage.read("test.txt").then(function(content) { console.log(content);
});
}
});
But I still get {"åäö":"å
insted of {"åäö":"åäö"}
?
What is the target/platform you are running?
If you’re on Windows this is probably due to the unicode bug that was reported before: https://www.fusetools.com/community/forums/bug_reports/09857_introduces_unicodeutf-8_issue
This will be fixed in Fuse 0.9.11.