void OnCommit(object sender, Gtk.CommitArgs ca) { try { if (selectionRelativeIndex != 0) { DeleteSelection(); } for (int i = 0; i < ca.Str.Length; i++) { char utf32Char; if (char.IsHighSurrogate(ca.Str, i)) { utf32Char = (char)char.ConvertToUtf32(ca.Str, i); i++; } else { utf32Char = ca.Str[i]; } lines[linePos] = lines[linePos].Insert(textPos, utf32Char.ToString()); textMode = TextMode.Uncommitted; textPos += utf32Char.ToString().Length; } Recalculate(); } finally { imContext.Reset(); } }