UTF-8 string character count in C/C++
The following code defines, tests and illustrates the use of utf8len() function. Which is a small piece of code for counting characters in UTF-8 (multibyte) string. Compile this example with GCC by running: $ gcc utf8len.c -lrt -o utf8len The RT library is used for the high precision clock only, you don’t need to link it if you are using the function itself into your own code. This utf8len() function provides a portable (and small footprint) way of counting UTF-8 charactes in standard C or C++.