Unicode literals

A wchar_t variable can also be initialized with a character and the compiler will promote the character to a wide character essentially by using the character's byte and assigning the remaining (higher) bytes to zero. However, it makes more sense to assign such a variable with a wide character, and you do this using the L prefix.

    wchar_t dollar = L'$';     wchar_t euro = L'\u20a0';     wcout << dollar;

Notice that, rather than using the cout object, this code uses wcout, the wide character version. The syntax of using the \u prefix within the quotes indicates that the following character is a Unicode character.

Bear in mind that, to show the Unicode character, you need to use a console that will show Unicode characters and, by ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.