javascript/library: Print data as raw bytes to stdout so unicode works.

This commit is contained in:
Damien George 2019-04-28 22:39:41 +10:00
parent bd6fed8201
commit d1dea4f577
1 changed files with 4 additions and 2 deletions

View File

@ -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;