防止将前同步码发送到流程的StandardInput [英] Prevent preamble sending to the StandardInput of a process
问题描述
您好!
我试图通过System.Diagnostics.Process类调用shell命令,并希望通过
+ Process.StandardInout StreamWriter向他们发送一些输入. >我的问题是,此StreamWriter某种程度上(可能是通过某些系统默认值)设置为使用UTF-8编码,因此发送了"ef bb bf"的字节顺序makr(BOM).在我将数据作为序言之前.正是这些字节搞砸了
shell应用程序(在本例中为openssl).
我知道我可以在新的StreamWriter中禁用它,但是我没有发现可能以任何方式更改
Process.StandardInput StreamWriter. ProcessStartInfo只允许我设置StadndrdOutput和
StandrdError的编码.
有谁知道,我如何才能真正更改Process.StandardInput的编码? Mathias
Hello!
I am trying to call shell commands via the System.Diagnostics.Process class and want to send them some input through the
+Process.StandardInout StreamWriter.
My problem is, that this StreamWriter is somehow (probably through some system default) set to use UTF-8 encoding and
thus sends the byte order makr (BOM) of "ef bb bf" before my data as a preamble. And exactly these bytes are screwing up
the shell applications (in this case: openssl).
I know that I can disable this in a new StreamWriter, but I did not find an y possibility to change the
Process.StandardInput StreamWriter in any way. ProcessStartInfo only allows me to set the encoding of StadndrdOutput and
StandrdError.
Does anyone know, how I can actually change the encoding of Process.StandardInput?
cheers
Mathias
推荐答案
已经讨论过:
这篇关于防止将前同步码发送到流程的StandardInput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!