the outputData has some unrecognized text?

mc 4,636 Reputation points
2023-10-08T06:56:21.13+00:00
var processInfo = new ProcessStartInfo
{
    FileName = "cmd.exe",
    Arguments = "",
    UseShellExecute = false,
    RedirectStandardError = true,
    RedirectStandardInput = true,
        RedirectStandardInput = true, 
    RedirectStandardOutput = true,
     CreateNoWindow = true 
};
 _process.StartInfo = processInfo; 
_process.OutputDataReceived += _process_OutputDataReceived; 
_process.ErrorDataReceived += _process_ErrorDataReceived;
_process.Start();
_process.BeginOutputReadLine();
_process.BeginErrorReadLine();

there is "楹﹀厠椋?" in output and I try get it by different encoding but is same.

it is unicode character

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,922 questions
.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
337 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,022 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,167 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 66,706 Reputation points
    2023-10-08T17:13:40.8633333+00:00

    Most likely the subprocess app is writing Unicode to the standard output. Try:

    new ProcessStartInfo
    {
         StandardOutputEncoding = Encoding.UTF8,
         StandardErrorEncoding =  Encoding.UTF8,
    …
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.