0

In my WPF app, when I attempt to use Console.WriteLine for debugging purposes, I get a ? in the "Output" window when writing unicode characters.

Console.WriteLine("こんにちは!");
// Output: ?????!

The solution mentioned in many other threads does not seem to work with WPF

Console.OutputEncoding = Encoding.UTF8; // Crashes

Is it possible to get unicode to work in the output tab?

BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283

1 Answers1

3

Technically there is no Console in WPF, however certain console commands seemingly do redirect to the output window. In short the Console is a special beast with its own set of limitation and quirks.

For debugging, use Debug.WriteLine to write to the output window instead.

Debug.WriteLine("こんにちは!");

enter image description here

TheGeneral
  • 79,002
  • 9
  • 103
  • 141
  • Wow, it's weird that `Debug.WriteLine` works but `Console.WriteLine` doesn't. Thanks! – BlueRaja - Danny Pflughoeft Aug 02 '20 at 07:17
  • 1
    @TheGeneral, How come the Console.WriteLine works at all without the console? wasnt the Visual Studio Hosting Process removed in vs 2017? And why does it seem to work under Framework but not under Core? Seems rather odd – Black Lotus Aug 04 '20 at 00:07
  • 2
    @BlackLotus yeah these are interesting questions, without doing some research i really have no answers. Maybe you could ask a question, i am sure that someone would know the answers. Or maybe ask on github why it was removed – TheGeneral Aug 04 '20 at 00:12
  • @TheGeneral, Thank you. Thought it was worth a shot, been searching around for a while but been unable to find much information about it. Might make a post about it, would be rather intrested to know. – Black Lotus Aug 04 '20 at 00:14