C - strlen() for utf-8 string

size_t count_utf8_code_points(const char *s) {
    size_t count = 0;
    while (*s) {
        count += (*s++ & 0xC0) != 0x80;
    }
    return count;
}

你可能感兴趣的:(C - strlen() for utf-8 string)