小编Mus*_*afa的帖子

process.standardInput编码问题

我对process.standartInput编码的编码有问题.我在我的Windows窗体应用程序中使用了一些进程,但输入应该是UTF-8.Process.StandardInput.Encoding是只读的,因此我无法将其设置为UTF-8,并且它获得了Windows默认编码,这会恶化UTF-8中的原生字符.程序中使用了2个进程,一个将输出写入文件和其他读取.因为我可以将输出编码设置为UTF-8,这部分工作正常,但回读是我遇到问题的部分.我将包括我使用该过程的部分.

ProcessStartInfo info = new ProcessStartInfo("mysql");
info.RedirectStandardInput = true;
info.RedirectStandardOutput = false;
info.Arguments = mysqldumpstring;
info.UseShellExecute = false;
info.CreateNoWindow = true;
Process p1 = new Process();
p1.StartInfo = info;
p1.Start();
string res = file.ReadToEnd();
file.Close();
MessageBox.Show(p1.StandardInput.Encoding.EncodingName); //= where encoding should be Encoding.UTF8;
p1.StandardInput.WriteLine(res);
p1.Close(); 
Run Code Online (Sandbox Code Playgroud)

c# encoding process utf-8

16
推荐指数
4
解决办法
7446
查看次数

标签 统计

c# ×1

encoding ×1

process ×1

utf-8 ×1