Получение фактической длины std::string в кодировке UTF-8? ⇐ C++
-
Anonymous
Получение фактической длины std::string в кодировке UTF-8?
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 used to represent a character. The sequence to be used depends on the UCS code number of the character:
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
Источник: https://stackoverflow.com/questions/406 ... -stdstring
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 used to represent a character. The sequence to be used depends on the UCS code number of the character:
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
Источник: https://stackoverflow.com/questions/406 ... -stdstring
Мобильная версия