Working with the wide character constant
Use the L constant for ASCII characters only. For ASCII characters, the L constant value is numerically the same as the code point value of the character. For example, L'a' is same as a. TheL constant obtains the wchar_t value of an ASCII character for assignment purposes. A wide character constant is introduced by the L specifier. For example:
wchar_t wc = L'x' ;
A wide character code corresponding to the character x
is
stored in wc
. The C compiler converts the character x
using
the mbtowc or mbstowcs subroutine as appropriate. This
conversion to wide characters is based on the current locale setting
at compile time. Because ASCII characters are part of all supported
code sets and the wide character representation of all ASCII characters
is the same in all locales, L'x'
results in the
same value across all code sets. However, if the character x
is
non-ASCII, the program may not work when it is run on a different
code set than used at compile time. This limitation impacts some
programs that use switch statements using the wide character constant
representation.