Answer the question
In order to leave comments, you need to log in
When is it better to use wchar_t, char16_t, char32_t instead of char in C++?
I read it, but I didn't fully understand it.
C++20 standard.
Answer the question
In order to leave comments, you need to log in
In cases where you want to use UTF-16LE, UTF-16 or UTF-32 respectively.
If you want to use an eight-bit encoding or UTF-8, then take char or char8_t, the latter is made specifically for UTF-8
wchar_t is used when it is necessary to input/output strings to winapi graphical components
Under Windows, it's better to always use wchar_t, because The Windows kernel internally uses wchar_t for strings. All WinAPI functions that accept strings as char* simply convert them to wchar_t and call the appropriate function for wide characters. So for some optimization it is better to use wchar_t right away.
In Linux, UTF8 is now ubiquitous. Unless you have to write for older kernels/distributions.
Other types - then when you work with data in the appropriate encodings.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question