Unicode in Console App - C#

Shervan360 1,661 Reputation points
2022-11-20T23:34:03.033+00:00

Hello,

I wrote a program to show UTF-16 emojis in Console App. When I ran the console app in PS from windows terminal, I can see emojis. But If I ran the program in PS without a windows terminal, I can't see it.
Please see:

262299-screenshot-2022-11-20-152756.png

Console.OutputEncoding = System.Text.Encoding.Unicode;  

Console.WriteLine("\uD83D\uDE02");  
Windows for business Windows Server User experience PowerShell
Developer technologies C#
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2022-11-21T01:16:48.513+00:00

    Console applications do not support Emojis. There are request to Microsoft back several years but nothing at this time.


  2. Lex Li (Microsoft) 6,037 Reputation points Microsoft Employee
    2022-11-23T05:49:07.617+00:00

    Actually what you observed is just one of main driving forces of Windows Terminal.

    The legacy Windows command line (either command prompt or PowerShell console) is simply too old to support Unicode based output, as documented in https://devblogs.microsoft.com/commandline/windows-command-line-unicode-and-utf-8-output-text-buffer/

    So, as you found out, stick to Windows Terminal (or any other terminal with Unicode support) and that's your only option to see Unicode characters.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.