This is because UTF-8 (the main/preferred string encoding in our libs, but this also applies to UTF-16) is multi-byte encoded. If you want a count of actual glyphs and not just the byte length, then convert the string to UTF-32 first (it is not a multi-byte encoding). See the hdi:core:: string namespace for functions to handle such a conversion.
|
Messages In This Thread |
accurate string length for UTF-8 std::strings - by Rick Johnson - 02-01-2021, 01:34 PM
RE: accurate string length for UTF-8 std::strings - by Rick Johnson - 02-02-2021, 03:26 PM
RE: accurate string length for UTF-8 std::strings - by garrett - 02-03-2021, 01:16 AM
|