I have a WPF application that also writes to stdout
because it can operate in two modes, UI or console. The output contains non-ascii characters, e.g.
Console.WriteLine("ÀÁÂÃÄÅÆ ®¯°±¹²³¼½¾¶·")
The result is a stream that I can redirect into a file and the file is encoded as ISO-8859
but I want it to be UTF-8
.
For console applications this answer suggests to set
Console.OutputEncoding = System.Text.Encoding.UTF8;
But when I do that in my application I get
System.IO.IOException "The handle is invalid" when setting OutputEncoding