MCPcopy Index your code
hub / github.com/git/git / utf8_strnwidth

Function utf8_strnwidth

utf8.c:211–234  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

209 * if the string does not look like a valid utf8 string.
210 */
211int utf8_strnwidth(const char *string, size_t len, int skip_ansi)
212{
213 const char *orig = string;
214 size_t width = 0;
215
216 while (string && string < orig + len) {
217 int glyph_width;
218 size_t skip;
219
220 while (skip_ansi &&
221 (skip = display_mode_esc_sequence_len(string)) != 0)
222 string += skip;
223
224 glyph_width = utf8_width(&string, NULL);
225 if (glyph_width > 0)
226 width += glyph_width;
227 }
228
229 /*
230 * TODO: fix the interface of this function and `utf8_strwidth()` to
231 * return `size_t` instead of `int`.
232 */
233 return cast_size_t_to_int(string ? width : len);
234}
235
236int utf8_strwidth(const char *string)
237{

Callers 8

utf8_strwidthFunction · 0.85
strbuf_utf8_alignFunction · 0.85
format_and_pad_commitFunction · 0.85
item_lengthFunction · 0.85
show_statsFunction · 0.85

Calls 3

utf8_widthFunction · 0.85
cast_size_t_to_intFunction · 0.85