I’m trying to capture output from a console application by running it in a test using System.Diagnostics.Process. I’m having trouble with character encoding. “£” is showing up as “œ” in the test, but when I run the console application it displays correctly as “£”.
If I set Console.Out.Encoding = Encoding.Default, it works in the tests but doesn’t display properly when running normally.
What’s going on here and how do I fix it?
You need to set the
StandardOutputEncodingon yourProcessStartInfoobject in your test case:You can find what CodePage you are using in your console app by running
which returns 850 (Western European DOS)
You could also use the
BodyNameproperty as an arg toGetEncodingthat is: