Skip to content

Commit

Permalink
输出重定向的文本编码转换
Browse files Browse the repository at this point in the history
  • Loading branch information
chsbuffer committed Jul 24, 2020
1 parent 75045fe commit 6174e78
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Netch/Controllers/Interface/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using Netch.Models;
using Netch.Utils;

Expand Down Expand Up @@ -131,8 +132,10 @@ public Process GetProcess()
/// <param name="e">数据</param>
protected void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
{
var str = Encoding.UTF8.GetString(Encoding.GetEncoding("gbk").GetBytes(e.Data??string.Empty));

// 写入日志
if (!Write(e.Data)) return;
if (!Write(str)) return;

// 检查启动
if (State == State.Starting)
Expand All @@ -146,7 +149,7 @@ protected void OnOutputDataReceived(object sender, DataReceivedEventArgs e)

foreach (var s in _startedKeywords)
{
if (e.Data.Contains(s))
if (str.Contains(s))
{
State = State.Started;

Expand All @@ -156,7 +159,7 @@ protected void OnOutputDataReceived(object sender, DataReceivedEventArgs e)

foreach (var s in _stoppedKeywords)
{
if (e.Data.Contains(s))
if (str.Contains(s))
{
State = State.Stopped;

Expand Down

0 comments on commit 6174e78

Please sign in to comment.