How to output using std::cout << ("") << std::endl; tick on the screen.

3 answers 3

For example:

 cout << "\u2713" <<endl; 

Or other ticks on the link: Tick

  • one
    Almost certainly it will not work in the Windows console. What encoding does the "\u2713" line get? (Does it depend on the compiler? IDE settings?) - jfs

My sincere advice: because the output to the console depends on a lot of factors - wide characters are used or not, encoding, etc. - do not bother, but use something similar. Well, what's the point in the console to direct this beauty? :)

Print any v that will be the same everywhere - because you are unlikely to mix it up with a letter.

  • Well, the console, this is just for the test ... and so, everything will be output in a PDF file :) - Insider
  • Well, for the test it will definitely come down :) How do you like the option - [v] or [ ] ? - Harry
  • Also not bad, you will need to think :) - Insider

A check mark can be represented by a Unicode symbol ✓ (U + 2713) . In this case, your question boils down to: “how to display Unicode on screen in c ++”, which may depend on the platform.

On Windows, in order to output arbitrary characters to the console, despite the current codepage, you can use the WriteConsoleW() API or the equivalent ( _O_U16TEXT mode and wprintf() with wchar_t lines, see. How to display Russian text? ). It is necessary to set the font in the console, which can display. Picking locale or SetConsoleOutputCP() will not help with Unicode in general.

On other systems, you can simply output utf-8 (assuming that the terminal uses utf-8), for example in c ++ 11 :

 cout << u8"\u2713"; 

You can use boost::nowide::cout for portability: utf-8 strings are automatically decoded and WriteConsoleW() behind the frame, if necessary .