Skip to content

Commit 32487ce

Browse files
author
Joachim Marder
committed
Fixed Encoding problem: PowerShell uses OEM encoding, no the default system code page.
1 parent 3027e00 commit 32487ce

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Designer/Classes/RibbonCompiler.pas

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function TRibbonCompiler.Execute(const Application, CurrentDir: String;
165165
ReadPipe, WritePipe: THandle;
166166
CmdLine, Param: String;
167167
AppRunning, BytesRead, BytesAvail, BytesLeft: Cardinal;
168-
Buffer: array [0..1023] of AnsiChar;
168+
Buffer: TBytes;
169169
ExitCode: Cardinal;
170170

171171
procedure LogBuffer;
@@ -174,10 +174,11 @@ function TRibbonCompiler.Execute(const Application, CurrentDir: String;
174174
begin
175175
if BytesRead = 0 then
176176
exit;
177-
Buffer[BytesRead] := #0;
178-
{$WARNINGS OFF}
179-
S := String(Buffer);
180-
{$WARNINGS ON}
177+
Buffer[BytesRead] := 0;
178+
With TEncoding.GetEncoding(CP_OEMCP) do begin
179+
S := GetString(Buffer);
180+
Free;
181+
end;
181182
DoMessage(mkPipe, S);
182183
end;
183184

@@ -219,17 +220,18 @@ function TRibbonCompiler.Execute(const Application, CurrentDir: String;
219220
end;
220221

221222
try
223+
SetLength(Buffer, 1024);
222224
repeat
223225
BytesRead := 0;
224226
AppRunning := WaitForSingleObject(ProcessInfo.hProcess, 10);
225227
if (AppRunning <> WAIT_TIMEOUT) then
226228
begin
227-
PeekNamedPipe(ReadPipe, @Buffer[0], SizeOf(Buffer) -1, @BytesRead, @BytesAvail, @BytesLeft);
229+
PeekNamedPipe(ReadPipe, @Buffer[0], Length(Buffer) -1, @BytesRead, @BytesAvail, @BytesLeft);
228230
LogBuffer;
229231
Break;
230232
end;
231233

232-
if (not ReadFile(ReadPipe, Buffer[0], SizeOf(Buffer) div 20, BytesRead, nil)) then // Read smaller chunks for continuous output
234+
if (not ReadFile(ReadPipe, Buffer[0], Length(Buffer) div 20, BytesRead, nil)) then // Read smaller chunks for continuous output
233235
Break;
234236
LogBuffer;
235237
until (BytesRead = 0);

0 commit comments

Comments
 (0)