src/utils/string.cpp
/**
   * Counts the number of codepoints in a utf8 encoded string.
   */
Counts the number of codepoints in a utf8 encoded string.
Counts the number of codepoints in a utf8 encoded string .
size_t char_len(const string& value) {
     0xc0 = 11000000
     0x80 = 10000000
    return std::count_if(value.begin(), value.end(), [](char c) { return (c & 0xc0) != 0x80; });
  }
size_t char_len ( const string & value ) { return std :: count_if ( value . begin ( ) , value . end ( ) , [ ] ( char c ) { return ( c & 0xc0 ) != 0x80 ; } ) ; }
Counts the number of codepoints in a utf8 encoded string.
Counts the number of codepoints in a utf8 encoded string .
// utf-8 bytes of the form 10xxxxxx are continuation bytes, so we // simply count the number of bytes not of this form. // // 0xc0 = 11000000 // 0x80 = 10000000