From b9b5eaccaeef615cad1465cbed6cab6d60a3c65f Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 6 Jan 2016 12:27:41 +0000 Subject: [PATCH] better handle utf8 file output chars --- nodes/core/storage/50-file.js | 1 + 1 file changed, 1 insertion(+) diff --git a/nodes/core/storage/50-file.js b/nodes/core/storage/50-file.js index 4f4c82d74..bb90927e7 100644 --- a/nodes/core/storage/50-file.js +++ b/nodes/core/storage/50-file.js @@ -42,6 +42,7 @@ module.exports = function(RED) { if (typeof data === "boolean") { data = data.toString(); } if (typeof data === "number") { data = data.toString(); } if ((this.appendNewline) && (!Buffer.isBuffer(data))) { data += os.EOL; } + data = new Buffer(data); if (this.overwriteFile === "true") { // using "binary" not {encoding:"binary"} to be 0.8 compatible for a while fs.writeFile(filename, data, "binary", function (err) {