From 8ab9c1b83fe8179c49cad53d25ef59a7134c7087 Mon Sep 17 00:00:00 2001 From: AlphaBs Date: Thu, 13 Jan 2022 21:20:19 +0900 Subject: [PATCH] set encoding of process output --- CmlLib/Utils/ProcessUtil.cs | 2 ++ CmlLibWinFormSample/MainForm.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CmlLib/Utils/ProcessUtil.cs b/CmlLib/Utils/ProcessUtil.cs index 61fd2e5..1ae65fd 100644 --- a/CmlLib/Utils/ProcessUtil.cs +++ b/CmlLib/Utils/ProcessUtil.cs @@ -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 ?? ""); diff --git a/CmlLibWinFormSample/MainForm.cs b/CmlLibWinFormSample/MainForm.cs index f5be089..d733853 100644 --- a/CmlLibWinFormSample/MainForm.cs +++ b/CmlLibWinFormSample/MainForm.cs @@ -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();