Preserve normalization for backspace-deletes-character
Submitted by Owen Taylor
Assigned to Behdad Esfahbod
Link to original bug (#155948)
Description
In the mythical lost original backspace-deletes-character patch for GtkTextView and GtkEntry, what I did was:
normalized_text = g_utf8_normalize (cluster_text, -1, G_NORMALIZE_NFD);
gboolean recompose = strcmp (normalized_text, cluster_text) != 0;
len = g_utf8_strlen (cluster_text, -1);
if (len > 1)
{
int bytelen = g_utf8_offset_to_pointer (normalized_text, len - 1) -
normalized_text; char *to_insert; if (recompose) to_insert = g_utf8_normalize (cluster_text, bytelen, G_NORMALIZE_NFC); else to_insert = g_strndup (cluster_text, bytelen);
/* insert text */
g_free (to_insert);
}
g_free (normalized_text);
This avoids a bug where deleting one accent off a precomposed form with two accents will give a decomposed form.