From 8cb0b193ea043bbd0d2a2162fa25f82aafaa50cd Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Wed, 4 Dec 2019 17:09:33 +0900 Subject: [PATCH] edje_entry: converting plain_text to '*' using unicode units. Summary: When converting plain_text to '*' in retrieve_surrounding_cb, always convert it to '*' in 1 byte unit. For example, 2 byte character is converted to "* *" and 3 byte character is converted to "* * *" However, this does not match the number of '*' printed in the entry. Because, '*' in the entry is printed according to number of unicode characters. This patch converts plain_text into unicode units when converting plain_text to '*' Test Plan: N/A Reviewers: woohyun Reviewed By: woohyun Subscribers: cedric, #reviewers, jihoon, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10792 --- src/lib/edje/edje_entry.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index 29e0f10c96..e87576b4ac 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -4736,9 +4736,23 @@ _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_ { if (ecore_imf_context_input_hint_get(ctx) & ECORE_IMF_INPUT_HINT_SENSITIVE_DATA) { + int idx = 0; char *itr = NULL; - for (itr = plain_text; itr && *itr; ++itr) - *itr = '*'; + size_t len = eina_unicode_utf8_get_len(plain_text); + char *u_text = (char *)malloc(len * sizeof(char) + 1); + if (!u_text) return EINA_FALSE; + + itr = u_text; + while (eina_unicode_utf8_next_get(plain_text, &idx)) + { + *itr = '*'; + itr++; + } + *itr = 0; + + plain_text = strdup(u_text); + free(u_text); + u_text = NULL; } *text = strdup(plain_text);