c++ - char vs wchar_t when to use which data type -


i want understand difference between char , wchar_t ? understand wchar_t uses more bytes can clear cut example differentiate when use char vs wchar_t

fundamentally, use wchar_t when encoding has more symbols char can contain.

background
char type has enough capacity hold character (encoding) in ascii character set.

the issue many languages require more encodings ascii accounts for. so, instead of 127 possible encodings, more needed. languages have more 256 possible encodings. char type not guarantee range greater 256. new data type required.

the wchar_t, a.k.a. wide characters, provides more room encodings.

summary
use char data type when range of encodings 256 or less, such ascii. use wchar_t when need capacity more 256.

prefer unicode handle large character sets (such emojis).


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -