From 5482f0be746a98bdd6b2c54183b54dd2ff2a0192 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Tue, 18 Oct 2022 19:33:41 +0100 Subject: Improve UTF-8 handling. This should allow case-insensitive matching for non-Latin characters, and fix matching for characters with diacritics. --- src/entry_backend/harfbuzz.c | 3 ++- src/entry_backend/pango.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/entry_backend') diff --git a/src/entry_backend/harfbuzz.c b/src/entry_backend/harfbuzz.c index c5fc07e..734d305 100644 --- a/src/entry_backend/harfbuzz.c +++ b/src/entry_backend/harfbuzz.c @@ -5,6 +5,7 @@ #include "../entry.h" #include "../log.h" #include "../nelem.h" +#include "../utf8.h" #include "../xmalloc.h" /* @@ -368,7 +369,7 @@ void entry_backend_harfbuzz_update(struct entry *entry) char *postmatch = NULL; cairo_text_extents_t subextents; if (entry->input_mb_length > 0 && entry->selection_highlight_color.a != 0) { - char *match_pos = strcasestr(prematch, entry->input_mb); + char *match_pos = utf8_strcasestr(prematch, entry->input_mb); if (match_pos != NULL) { match = xstrdup(result); prematch_len = (match_pos - prematch); diff --git a/src/entry_backend/pango.c b/src/entry_backend/pango.c index 1f19bce..1cc7628 100644 --- a/src/entry_backend/pango.c +++ b/src/entry_backend/pango.c @@ -4,6 +4,7 @@ #include "../entry.h" #include "../log.h" #include "../nelem.h" +#include "../utf8.h" #include "../xmalloc.h" #undef MAX @@ -181,7 +182,7 @@ void entry_backend_pango_update(struct entry *entry) PangoRectangle ink_subrect; PangoRectangle logical_subrect; if (entry->input_mb_length > 0 && entry->selection_highlight_color.a != 0) { - char *match_pos = strcasestr(str, entry->input_mb); + char *match_pos = utf8_strcasestr(str, entry->input_mb); if (match_pos != NULL) { prematch_len = (match_pos - str); postmatch_len = strlen(str) - prematch_len - match_len; -- cgit v1.2.3