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
This commit is contained in:
Bowon Ryu 2019-12-04 17:09:33 +09:00 committed by WooHyun Jung
parent 8f500460ad
commit 8cb0b193ea
1 changed files with 16 additions and 2 deletions

View File

@ -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);