Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c++11

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= 
like image 613
George Kourtis Avatar asked Jun 21 '14 09:06

George Kourtis


1 Answers

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"...";
like image 84
DrYap Avatar answered Nov 13 '22 22:11

DrYap