Using UNICODE Character Values ​​in C ++

How do you use unicode in c ++? I know about wchar_tand wchar_t*, but I want to know how you can assign a value using only Unicode values, similar to how you can assign a character by equating a variable to an ASCII value:

char a = 92;

Im uysing the MinGW compiler, if that matters.

+5
source share
2 answers

Similar:

wchar_t a = 97;
wchar_t xi = 0x03be; // ξ
+2
source

It could be simple:

wchar_t a=L'a';
wchar_t hello_world[]=L"Hello World";

// Or if you really want it to be (old school) C++ and not C

std::wstring s(L"Hello World");

// Or if you want to (be bleeding edge and) use C++11

std::u16string s16(u"Hello World");
std::u32string s32(U"Hello World for the ∞ᵗʰ time");
+9
source

All Articles