git-2.22.0/utf8.c
/*
 * Returns the total number of columns required by a null-terminated
 * string, assuming that the string is utf8.  Returns strlen() instead
 * if the string does not look like a valid utf8 string.
 */
Returns the total number of columns required by a null-terminated
string, assuming that the string is utf8.  Returns strlen() instead
if the string does not look like a valid utf8 string.
Returns the total number of columns required by a null - terminated string assuming that the string is utf8 . Returns strlen () instead if the string does not look like a valid utf8 string .
int utf8_strnwidth(const char *string, int len, int skip_ansi)
{
	int width = 0;
	const char *orig = string;
	if (len == -1)
		len = strlen(string);
	while (string && string < orig + len) {
		int skip;
		while (skip_ansi &&
		       (skip = display_mode_esc_sequence_len(string)) != 0)
			string += skip;
		width += utf8_width(&string, NULL);
	}
	return string ? width : len;
}
int utf8_strnwidth ( const char * string , int len , int skip_ansi ) { int width = 0 ; const char * orig = string ; if ( len == -1 ) len = strlen ( string ) ; while ( string && string < orig + len ) { int skip ; while ( skip_ansi && ( skip = display_mode_esc_sequence_len ( string ) ) != 0 ) string += skip ; width += utf8_width ( & string , NULL ) ; } return string ? width : len ; }
Returns the total number of columns required by a null-terminated
 string, assuming that the string is utf8.
Returns the total number of columns required by a null - terminated string assuming that the string is utf8 .