link-grammar-5.8.0/link-grammar/utilities.h
/**
 * Return the length, in codepoints/glyphs, of the utf8-encoded
 * string.  The string is assumed to be null-terminated.
 * This is needed when splitting words into morphemes.
 */
Return the length, in codepoints/glyphs, of the utf8-encoded
string.  The string is assumed to be null-terminated.
This is needed when splitting words into morphemes.
Return the length in codepoints / glyphs of the utf8 - encoded string . The string is assumed to be null - terminated . This is needed when splitting words into morphemes .
static inline size_t utf8_strlen(const char *s)
{
	mbstate_t mbss;
	memset(&mbss, 0, sizeof(mbss));
#if _WIN32
	return MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0)-1;
#else
	return mbsrtowcs(NULL, &s, 0, &mbss);
#endif 
}
static inline size_t utf8_strlen ( const char * s ) { mbstate_t mbss ; memset ( & mbss , 0 , sizeof ( mbss ) ) ; #if _WIN32 return MultiByteToWideChar ( CP_UTF8 , 0 , s , -1 , NULL , 0 ) - 1 ; #else return mbsrtowcs ( NULL , & s , 0 , & mbss ) ; #endif }
Return the length, in codepoints/glyphs, of the utf8-encoded
 string.
Return the length in codepoints / glyphs of the utf8 - encoded string .
/* _WIN32 */