Unicode in Console App - C#

Shervan360 1,601 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");  
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,995 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,546 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,431 Reputation points
    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) 5,582 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.