char s1[] = "中文ABC"; wchar_t s2[] = L"中文ABC"; 1.sizeof() /*獲取字符數(shù)組的字節(jié)數(shù)(包括結(jié)束符0)*/ sizeof(s1) = 8;ANSI sizeof(s2) = 12;UNICODE 2.strlen/wcslen /*采取0作為字符串的結(jié)束符,,并返回不包括0在內(nèi)的字符數(shù)目*/ strlen(s1) = 7;ANSI wcslen(s2) = 5;UNNICODE 3.GetLenth() /*返回字符而非字節(jié)數(shù)目*/ CStringA sa = s1;ANSI CStringW sw = s2;UNICODE sa.GetLength() = 7; sw.GetLength() = 5; 4.size()與GetLength()一樣 5.length() /*獲取字符數(shù)目的最佳方案*/ _bstr_t::length(); _bstr_t bs1 = s1; _bstr_t bs2 = s2; bs1.length() = 5;ANSI bs2.length() = 5;UNICODE |
|