mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-22 16:29:10 +02:00
* Solution for FPC flush() mid-codepoint.
This commit is contained in:
parent
5d3abdcc5d
commit
b030773e41
@ -1177,12 +1177,27 @@ end;
|
|||||||
|
|
||||||
procedure TPas2JSWASIEnvironment.DoConsoleWrite(IsStdErr: Boolean; aBytes: TJSUint8Array);
|
procedure TPas2JSWASIEnvironment.DoConsoleWrite(IsStdErr: Boolean; aBytes: TJSUint8Array);
|
||||||
|
|
||||||
|
Function TryConvert : string;
|
||||||
|
|
||||||
|
begin
|
||||||
|
asm
|
||||||
|
S=String.fromCharCode.apply(null, aBytes);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
S : String;
|
S : String;
|
||||||
Evt : TWASIWriteEvent;
|
Evt : TWASIWriteEvent;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
try
|
||||||
S:=UTF8TextDecoder.decode(aBytes);
|
S:=UTF8TextDecoder.decode(aBytes);
|
||||||
|
except
|
||||||
|
// Depending on buffer size, FPC can do a flush mid-codepoint.
|
||||||
|
// The resulting bytes will not form a complete codepoint at the end.
|
||||||
|
// So we try to convert what is possible...
|
||||||
|
S:=TryConvert
|
||||||
|
end;
|
||||||
if IsStdErr then
|
if IsStdErr then
|
||||||
evt:=FOnStdErrorWrite
|
evt:=FOnStdErrorWrite
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user