Given a std::string
containing text encoded in an arbitrary but known character set. What is the easiest way in C++ to count the characters? It should be able to handle things like combining characters and Unicode code points.
It would be nice to have something like:
std::string test = "éäöü";
std::cout << test.size("utf-8") << std::endl;
Unfortunately, life isn't always easy with C++. :)
For Unicode, I have seen that one can use the ICU library: Cross-platform iteration of Unicode string (counting Graphemes using ICU)
But is there a more general solution?