Skip to content

Commit

Permalink
set encoding of process output
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaBs committed Jan 13, 2022
1 parent d65d7ef commit 8ab9c1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CmlLib/Utils/ProcessUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public void StartWithEvents()
Process.StartInfo.UseShellExecute = false;
Process.StartInfo.RedirectStandardError = true;
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
Process.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;
Process.EnableRaisingEvents = true;
Process.ErrorDataReceived += (s, e) => OutputReceived?.Invoke(this, e.Data ?? "");
Process.OutputDataReceived += (s, e) => OutputReceived?.Invoke(this, e.Data ?? "");
Expand Down
2 changes: 2 additions & 0 deletions CmlLibWinFormSample/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ private void StartProcess(Process process)
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;
process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
process.EnableRaisingEvents = true;

process.Start();
Expand Down

0 comments on commit 8ab9c1b

Please sign in to comment.