aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/string-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string-utils.c')
-rw-r--r--src/string-utils.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/string-utils.c b/src/string-utils.c
index e9dd148..d98b6b0 100644
--- a/src/string-utils.c
+++ b/src/string-utils.c
@@ -87,8 +87,10 @@ teco_string_get_coord(const gchar *str, gsize off, guint *pos, guint *line, guin
}
/**
- * Get the length of the prefix common to two strings.
- * Works with UTF-8 and single-byte encodings.
+ * Get the length of the prefix common to two UTF-8 strings.
+ *
+ * The UTF-8 strings must be validated, which should be the case
+ * for help labels and short Q-Register names.
*
* @param a Left string.
* @param b Right string.
@@ -103,8 +105,8 @@ teco_string_diff(teco_string_t a, const gchar *b, gsize b_len)
gsize len = 0;
while (len < a.len && len < b_len &&
- a.data[len] == b[len])
- len++;
+ g_utf8_get_char(a.data+len) == g_utf8_get_char(b+len))
+ len = g_utf8_next_char(b+len) - b;
return len;
}