diff options
author | Damien George <damien.p.george@gmail.com> | 2019-04-28 22:39:41 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-04-28 22:39:41 +1000 |
commit | d1dea4f57701b9464e3d6c45a5814d58fb0795f9 (patch) | |
tree | af209966f0952cece8f0d81adf2cb049b79bea44 | |
parent | bd6fed8201a818a96611e56ecc521c23cf5255f4 (diff) |
javascript/library: Print data as raw bytes to stdout so unicode works.
-rw-r--r-- | ports/javascript/library.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ports/javascript/library.js b/ports/javascript/library.js index 85fa3e2ed..9aab3e432 100644 --- a/ports/javascript/library.js +++ b/ports/javascript/library.js @@ -27,10 +27,12 @@ mergeInto(LibraryManager.library, { mp_js_write: function(ptr, len) { for (var i = 0; i < len; ++i) { - c = String.fromCharCode(getValue(ptr + i, 'i8')); if (typeof window === 'undefined') { - process.stdout.write(c); + var b = Buffer.alloc(1); + b.writeInt8(getValue(ptr + i, 'i8')); + process.stdout.write(b); } else { + var c = String.fromCharCode(getValue(ptr + i, 'i8')); var mp_js_stdout = document.getElementById('mp_js_stdout'); var print = new Event('print'); print.data = c; |