title: How to deal with output from console applications that use control characters?
body: <p>I want to call an executable (in my case, this is PNGOUT.exe) and grab its output from stdout. But it turned out to be tricky - the application uses some sort of control characters to replace previously printed output (display of progress), and C# classes happily record them and when I want to analyze the output string, I get serious headache. (It even took a while for me to figure out what's happening with my string)</p>
  
  <p>I'm calling executable with following method:</p>
  
  <pre><code>public static string RunPNGOut(string pngOutPath, string target) {
     var process = new Process {
        StartInfo = {
           UseShellExecute = false,
           RedirectStandardOutput = true,
           CreateNoWindow = true,
           FileName = pngOutPath,
           Arguments = '"' + target + '"'
        }
     };
     process.Start();
  
     var result = process.StandardOutput.ReadToEnd();
  
     process.WaitForExit();
  
     return result;
  }
  </code></pre>
  
  <p>I need either use different method that captures only final state of text in console, or somehow get rid of control characters in <code>result</code>(not simply delete them, but "apply" them to string to achieve the final look). How can it be done?</p>