c++ - std::wstring length -
what result of std::wstring.length() function, length in wchar_t(s) or length in symbols? , why?
tchar r2[3]; r2[0] = 0xd834; // d834, dd1e - musical g clef r2[1] = 0xdd1e; // r2[2] = 0x0000; // '/0' std::wstring r = r2; std::cout << "capacity: " << r.capacity() << std::endl; std::cout << "length: " << r.length() << std::endl; std::cout << "size: " << r.size() << std::endl; std::cout << "max_size: " << r.max_size() << std::endl; output> capacity: 351 length: 2 size: 2 max_size: 2147483646
std::wstring::size()
returns number of wide-char elements in string. not same number of characters (as correctly noticed).
unfortunately, std::basic_string
template (and instantiations, such std::string
, std::wstring
) encoding-agnostic. in sense, template string of bytes , not string of characters.
Comments
Post a Comment