Return the number of logical characters (possibly multibyte) that are in string S in the first OFS octets. Example in UTF-8: "\xE2\x9D\xA7" is "U+2767 ROTATED FLORAL HEART BULLET". In the string below, there are only two characters up to the first 4 bytes (The U+2767 which occupies 3 bytes and 'x'): mbs_count_to_offset ("\xE2\x9D\xA7xyz", 4) => 2 */
| 213 | up to the first 4 bytes (The U+2767 which occupies 3 bytes and 'x'): |
| 214 | mbs_count_to_offset ("\xE2\x9D\xA7xyz", 4) => 2 */ |
| 215 | static size_t |
| 216 | mbs_offset_to_chars (char const *s, size_t ofs) |
| 217 | { |
| 218 | size_t c = 0; |
| 219 | for (size_t d = 0; d < ofs && s[d]; d += mcel_scanz (s + d).len) |
| 220 | c++; |
| 221 | return c; |
| 222 | } |
| 223 | |
| 224 | |
| 225 |