+static gboolean
+is_valid_insert (const gchar *text, gint len)
+{
+ gunichar c;
+ gint i= 0;
+ const gchar *current;
+ if (text == NULL)
+ return TRUE;
+ current = text;
+
+ while (((len == -1)||(i < len)) && (*text != '\0')) {
+ c = g_utf8_get_char (current);
+ if (c == 0x2022 || c == 0xfffc)
+ return FALSE;
+ current = g_utf8_next_char (current);
+ i = current - text;
+ }
+ return TRUE;
+}
+
+static gchar *
+create_valid_text (const gchar *text, gint len)
+{
+ gunichar c;
+ gint i= 0;
+ GString *str;
+ const gchar *current;
+
+ if (text == NULL)
+ return NULL;
+
+ str = g_string_new ("");
+ current = text;
+
+ while (((len == -1)||(i < len)) && (*text != '\0')) {
+ c = g_utf8_get_char (current);
+ if (c != 0x2022 && c != 0xfffc)
+ str = g_string_append_unichar (str, c);
+ current = g_utf8_next_char (current);
+ i = current - text;
+ }
+ return g_string_free (str, FALSE);
+}
+