@@ -206,7 +206,7 @@ int utf8_width(const char **start, size_t *remainder_p)
* 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, size_t len, int skip_ansi)
+size_t utf8_strnwidth(const char *string, size_t len, int skip_ansi)
{
const char *orig = string;
size_t width = 0;
@@ -224,14 +224,10 @@ int utf8_strnwidth(const char *string, size_t len, int skip_ansi)
width += glyph_width;
}
- /*
- * TODO: fix the interface of this function and `utf8_strwidth()` to
- * return `size_t` instead of `int`.
- */
- return cast_size_t_to_int(string ? width : len);
+ return string ? width : len;
}
-int utf8_strwidth(const char *string)
+size_t utf8_strwidth(const char *string)
{
return utf8_strnwidth(string, strlen(string), 0);
}
@@ -7,8 +7,8 @@ typedef unsigned int ucs_char_t; /* assuming 32bit int */
size_t display_mode_esc_sequence_len(const char *s);
int utf8_width(const char **start, size_t *remainder_p);
-int utf8_strnwidth(const char *string, size_t len, int skip_ansi);
-int utf8_strwidth(const char *string);
+size_t utf8_strnwidth(const char *string, size_t len, int skip_ansi);
+size_t utf8_strwidth(const char *string);
int is_utf8(const char *text);
int is_encoding_utf8(const char *name);
int same_encoding(const char *, const char *);