How can I declare a multibyte character array in which each is character is represented for 3 or 4 bytes?
I know I can do: char var[] = "AA"; which will write to memory 6161 and I can do wchar var[] = L"AA"; which will do 00610061. How can I declare a wider character array in C or C++?
Is there any other prefix like the L to instruct the compiler to do so?
Both C and C++ offer char32_t. In C char32_t is a typedef of/same type as uint_least32_t. In C++ char32_t has the same size, signedness, and alignment as std::uint_least32_t, but is a distinct type.
Both of them can be used like
char32_t string[] = U"some text";
You could try this, as long as you don't mind manually typing out each character:
int characters[3] = { 'h', 'e', 'y' };
You can also use a capital U in front of the string literal to get UTF-32:
char32_t characters[] = U"hey";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With