Bwana Lawi

Bwana Lawi

  • NA
  • 2
  • 23.2k

Printing unicode to console in C#

Sep 16 2017 7:56 AM
I can't get the Console to print unicode characters using the Console.WriteLine or Console.Out.WriteLine. After searching the Internet, I found two suggestions.
  1. Console.OutputEncoding = Encoding.UTF8;  // Option 1 for setting encoding    
  2. Console.WriteLine("Smiley face: ????");      
  3.       
  4. Console.OutputEncoding = System.Text.Encoding.UTF8;  //Option 2    
  5. Console.WriteLine("Smiley face: ????");    
Problem is that both these approaches give the same error below:
 
Smiley face: ????
Exception thrown: 'System.IO.IOException' in mscorlib.dll
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll
The handle is invalid.
 
I have changed the console font to Lucida Console but still the unicode characters are not being printed 
 
Environment:
IDE: VS Community version, 2017, Version 15.3.4
Windows 10
 

Answers (2)