A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Hi @Stewart Patch ,
Thanks for reaching out.
In C++, a character literal of type wchar_t is written using the L prefix in front of the character. That prefix tells the compiler you want a wide character instead of a regular char.
The basic format is:
L'character'
For example:
wchar_t ch1 = L'A';
wchar_t ch2 = L'中';
Both are valid wide character literals. The L is what makes the literal type wchar_t.
You can also use escape sequences the same way you would with normal character literals:
wchar_t newline = L'\n';
wchar_t hexChar = L'\x4E2D';
wchar_t unicode = L'\u4E2D';
A couple of important notes:
- The literal must contain exactly one character (after escape processing).
- The actual size of
wchar_tdepends on the platform (commonly 2 bytes on Windows and 4 bytes on many Unix/Linux systems).
For more details, as RLWA32 has mentioned, you can refer to this document.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.