Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fixing saving utf8 content in cordova

Ilianfcf5fc7d83bd
diff --git a/data/cordova/cordova.api.js b/data/cordova/cordova.api.js
index b8baaaece..2e52eff73 100644
--- a/data/cordova/cordova.api.js
+++ b/data/cordova/cordova.api.js
@@ -316,6 +316,15 @@ define(function (require, exports, module) {
console.log("Saving file: "+filePath);
TSCORE.showLoadingAnimation();
+ // Handling the UTF8 support for text files
+ var UTF8_BOM = "\ufeff";
+
+ if(content.indexOf(UTF8_BOM) == 0) {
+ // already has a UTF8 bom
+ } else {
+ content = UTF8_BOM+content;
+ }
+
filePath = normalizePath(filePath);
fsRoot.getFile(filePath, {create: true, exclusive: false},
function(entry) {