How to declare wstring or wchar_t literal in C++

In order to declare a wstring literal, use the L prefix:

wstring-literal.cpp
wstring w = L"Test: äöü";

In order to declare a wchar_t literal, you can also use the L prefix:

wchar-literal.cpp
wchar_t wc = L'ö';

Check out similar posts by category: C/C++