The programmed books often introduce Unicode, and there are also various formats in string functions. The following is to introduce as examples with "ABC I"
Test source code:
Tchar * p = _t ("abc I am you"); std :: cout << _tcsclen (p);
The code we wrote should be this, that is, both ANSI is in line with Unicode code, using the _t macro and _TS function set.
First, ANSI encoding: ordinary English letters, Chinese characters account for two bytes. "ABC I, you" occupy 9 bytes. There is no relevant option output in the compilation option 9 At this point, _tcsclen is Strlen, the result is the number of bytes.
Use multi-character functions, Multibyte functions, and build _mbcs in the compile option, which VC is generated by default (Project-> Setting-> C -> Preprocessor Setting). At this time _tcsclen is _MBSLEN. The output result is 6 and actually occupies 9 bytes.
Second, Unicode encoding, so-called wide character, English characters and Chinese characters occupy 2 bytes, the compilation option is set _unicode, Unicode source code equivalent to wchar_t * p = L "abc I am you"; std :: cout << wcslen (p); the result is 6, actually occupying 12 bytes. ;