File tree 2 files changed +7
-11
lines changed
2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ something to stdout. The following code demonstrates basic functionality:
70
70
<script >
71
71
document .addEventListener (" micropython-print" , function (e ) {
72
72
let output = document .getElementById (" micropython-stdout" );
73
- output .innerText += e .detail ;
73
+ output .innerText += new TextDecoder (). decode ( e .detail ) ;
74
74
}, false );
75
75
76
76
var mp_js_startup = Module[" onRuntimeInitialized" ];
Original file line number Diff line number Diff line change 26
26
27
27
mergeInto ( LibraryManager . library , {
28
28
mp_js_write : function ( ptr , len ) {
29
- for ( var i = 0 ; i < len ; ++ i ) {
30
- if ( typeof window === 'undefined' ) {
31
- var b = Buffer . alloc ( 1 ) ;
32
- b . writeInt8 ( getValue ( ptr + i , 'i8' ) ) ;
33
- process . stdout . write ( b ) ;
34
- } else {
35
- var c = String . fromCharCode ( getValue ( ptr + i , 'i8' ) ) ;
36
- var printEvent = new CustomEvent ( 'micropython-print' , { detail : c } ) ;
37
- document . dispatchEvent ( printEvent ) ;
38
- }
29
+ const buffer = HEAPU8 . subarray ( ptr , ptr + len )
30
+ if ( typeof window === 'undefined' ) {
31
+ process . stdout . write ( buffer ) ;
32
+ } else {
33
+ const printEvent = new CustomEvent ( 'micropython-print' , { detail : buffer } ) ;
34
+ document . dispatchEvent ( printEvent ) ;
39
35
}
40
36
} ,
41
37
You can’t perform that action at this time.
0 commit comments