1

I was trying to print emoji through python but it shows up as a question mark in the box.

print("\U0001f600") 

IMAGE

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
Ahanaful Alam
  • 45
  • 1
  • 1
  • 4
  • You may need to specify the correct font as suggested by [this thread](https://stackoverflow.com/questions/10764920/utf-16-on-cmd-exe). – metatoaster Jul 05 '20 at 09:19
  • 1
    The Windows command prompt is a text user interface. So why do you want to output graphic symbols like emojis on a pure text interface at all? The font configured for drawing characters and symbols into a Windows console window must support the characters and symbols you want to see in the console window. I am not aware of any font which supports really all characters and symbols defined by the Unicode consortium with fixed width per character/symbol. There are some fonts which support thousands of characters, but none which supports really all characters and symbols. – Mofi Jul 05 '20 at 09:56
  • Internet browsers use often automatically a different font than the font specified with CSS if this font does not support a character to display. Most visitors of a webpage don't see that some characters are displayed with a different font. The internet browsers are installed with a library full of small graphics to display emojis which is the reason why most emojis look slightly different depending on which internet browser is used by the viewer of a webpage. Emojis are graphic symbols which should not be used in a (monochrome or 16 colors) text window at all. – Mofi Jul 05 '20 at 10:02

1 Answers1

4

The Windows default console host (conhost.exe) does not support printing Unicode characters. However, the new Windows Terminal does. Run that code in the Windows Terminal (wt.exe), because it has fully Unicode support.

Anic17
  • 712
  • 5
  • 18
  • Could you please tell me how to make windows terminal to run my c++ code from code locks or dev c++ in stead of command prompt? – Ahanaful Alam Jul 05 '20 at 13:14
  • 1
    Command Prompt DOES support Unicode. 1/ You must turn it on. (`chcp 65001` does UTF8). This is so MSDos batch files will run. 2/ You must choose a font with the characters you want. –  Jul 05 '20 at 17:09
  • I have said that cmd doesn't support printing Unicode, not that it doesn't support Unicode. Try printing an Unicode character to the screen, it will give you an interrogation symbol. Please read carefully my answer. – Anic17 Jul 06 '20 at 10:33
  • I don't know what you are on about. Here we are do code 8719 _N-Ary Product_ character. `chcp 65001` then `echo ∏` prints `∏`. I have Consolas font selected. –  Jul 07 '20 at 00:36
  • Ahanaful Alam, what do you mean? If you mean the compiler, Code::Blocks comes with GCC, so compile a C++ file by using that command line: `gcc main.cpp` – Anic17 Aug 15 '20 at 20:38
  • ∏ is part of the Consolas font so displays correctly, for example isn't and won't display correctly. You can use the windows Font Settings app to check this – Superfly Jon Mar 01 '23 at 09:31