George Kourtis
George Kourtis

Reputation: 2592

Assign a literal to an std::u16string or to an std::u32string

As I know I may assign to a string a literal value as:

std::string s="good";
std::wstring s=L"good";

how do I assign to a

std::u16string s= 
std::u32string s= 

Upvotes: 13

Views: 5064

Answers (1)

DrYap
DrYap

Reputation: 6647

You can read about the C++ string literals here.

In particular for UTF-16 literals you prefix with a lowercase u:

u16string s = u"...";

And for UTF-32 literals you prefix with a uppercase U:

u32string s = U"...";

Upvotes: 26

Related Questions