If you need only to count the number of Unicode characters in your UTF-8 string and you do not want to pull a full-blown Unicode library, here is the C++ snippet: std::count_if(std::begin(v), std::end(v), [](auto c) { return (static_cast<unsigned char>(c) & 0b1100'0000) != 0b1000'0000; })