diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index fdf8157cd4..dcd7e24c93 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -340,29 +340,20 @@ Zotero.File = new function(){ path = path.path; } - if (typeof data == 'string' && (!charset || charset.toLowerCase() == 'utf-8')) { - let encoder = new TextEncoder(); - let array = encoder.encode(data); + if (typeof data == 'string') { return Zotero.Promise.resolve(OS.File.writeAtomic( path, - array, + data, { tmpPath: OS.Path.join( Zotero.getTempDirectory().path, OS.Path.basename(path) + ".tmp" - ) + ), + encoding: charset ? charset.toLowerCase() : 'utf-8' } )); } - // Convert text data to stream - if(!(data instanceof Components.interfaces.nsIInputStream)) { - var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]. - createInstance(Components.interfaces.nsIScriptableUnicodeConverter); - converter.charset = charset ? Zotero.CharacterSets.getName(charset) : "UTF-8"; - data = converter.convertToInputStream(data); - } - var deferred = Zotero.Promise.defer(); var os = FileUtils.openSafeFileOutputStream(new FileUtils.File(path)); NetUtil.asyncCopy(data, os, function(inputStream, status) {