Getting the actual length of a UTF-8 encoded std::string?

my std::string is utf-8 encoded so obviously, str.length() returns the wrong result.

I found this information but I'm not sure how I can use it to do this:

The following byte sequences are используется для обозначения персонажа. В последовательность быть использование зависит от номера кода UCS символа:

  0x00000000 - 0x0000007F:
 0xxxxxxx

 0x00000080 - 0x000007FF:
 110xxxxx 10xxxxxx

 0x00000800 - 0x0000FFFF:
 1110xxxx 10xxxxxx 10xxxxxx

 0x00010000 - 0x001FFFFF:
 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

How can I find the actual length of a UTF-8 encoded std::string? Thanks

32
задан Andrew Medico 31 October 2010 в 15:45
поделиться