What's the difference between char, wchar_t? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the difference between char, wchar_t?

char wchar_t

21st Apr 2018, 3:41 PM
Ziyad Aldoumany
Ziyad Aldoumany - avatar
2 Answers
+ 6
char is used for so called ANSI family of functions (typically function name ends with A), or more commonly known as using ASCII character set. wchar_t is used for new so called Unicode (or Wide) family of functions (typically function name ends with W), which use UTF-16 character set. It is very similar to UCS-2, but not quite it. If character requires more than 2 bytes, it will be converted into 2 composite codepoints, and this can be very confusing. If you want to convert one to another, it is not really simple task. You will need to use something like MultiByteToWideChar, which requires knowing and providing code page for input ANSI string. SOURCE: https://stackoverflow.com/questions/19532785/difference-between-char-and-wchar-t
21st Apr 2018, 3:58 PM
Baraa AB
Baraa AB - avatar
+ 1
wchar_t is 2 bytes long and supports the UTF16 unicode standard. More national and special characters are available.
21st Apr 2018, 3:53 PM
Timon Paßlick