String literals
suggest changeString literals are used to specify arrays of characters. They are sequences of characters enclosed within double quotes (e.g. "abcd"
and have the type char*
).
The L
prefix makes the literal a wide character array, of type wchar_t*
. For example, L"abcd"
.
Since C11, there are other encoding prefixes, similar to L
:
prefix | base type | encoding |
—— | —— |—— |
none | char
| platform dependent |L
| wchar_t
| platform dependent |u8
| char
| UTF-8 |u
| char16_t
| usually UTF-16 |U
| char32_t
| usually UTF-32 |
For the latter two, it can be queried with feature test macros if the encoding is effectively the corresponding UTF encoding.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents