diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-29 16:37:58 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-29 16:42:09 +1000 |
commit | 32b88f3eb447450f0db3c089f89d895f64ff3202 (patch) | |
tree | d06dcaf565c52845c0166e9b6feb4bccc71dda8c | |
parent | c1495c926824deb9628b5e912e1c36a9980bef28 (diff) | |
download | fengari-32b88f3eb447450f0db3c089f89d895f64ff3202.tar.gz fengari-32b88f3eb447450f0db3c089f89d895f64ff3202.tar.bz2 fengari-32b88f3eb447450f0db3c089f89d895f64ff3202.zip |
src/lbaselib.js: Make print() correctly handle 8bit chars under node
-rw-r--r-- | src/lbaselib.js | 6 |
1 files changed, 4 insertions, 2 deletions
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; }; |