I am collecting application output in my .NET application.
The encoding is somewhat strange. ÅÄÖ letters are displayed as ├Ñ ├├ ├Â
I tried to convert back and forth from different encodings without any success. Does anyone know how a string should be correctly converted here?
eg. the documentation for the application says that the output is UTF8, so I tried this:
byte[] encodedBytes = Encoding.UTF8.GetBytes(theOutput); var res = Encoding.Default.GetString(encodedBytes);
What causes the wrong result.
edit: code:
var processStartInfo = new ProcessStartInfo { CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardInput = true, UseShellExecute = false, Arguments = a, FileName = path + "\\phantomjs.exe" }; var process = new Process { StartInfo = processStartInfo, EnableRaisingEvents = true }; //capturing output here process.OutputDataReceived += (sender, args) => outputBuilder.Append(args.Data); process.Start(); process.BeginOutputReadLine(); process.WaitForExit(20000); process.CancelOutputRead();
source share