From 32b88f3eb447450f0db3c089f89d895f64ff3202 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 29 May 2017 16:37:58 +1000 Subject: src/lbaselib.js: Make print() correctly handle 8bit chars under node --- src/lbaselib.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lbaselib.js b/src/lbaselib.js index dfd39bb..5a17aa8 100644 --- a/src/lbaselib.js +++ b/src/lbaselib.js @@ -21,8 +21,10 @@ const luaB_print = function(L) { } // Don't use console.log if Node - if (process.stdout) process.stdout.write(lua.to_jsstring(str) + "\n"); - else console.log(lua.to_jsstring(str)); + if (process.stdout) { + str.push("\n".charCodeAt(0)); + process.stdout.write(Buffer.from(str)); + } else console.log(lua.to_jsstring(str)); return 0; }; -- cgit v1.2.3-70-g09d2