static gchar *
exists_helper (const gchar *ps1,
               const gchar *ps2)
{
	gchar *res;
	gchar *s1 = e_util_utf8_remove_accents (ps1);
	gchar *s2 = e_util_utf8_remove_accents (ps2);

	res = (gchar *) e_util_utf8_strstrcase (s1, s2);

	g_free (s1);
	g_free (s2);

	return res;
}
/* converts str into utf8 GString in lowercase;
 * returns NULL if str is invalid utf8 string otherwise
 * returns newly allocated GString
*/
static GString *
chars_to_unistring_lowercase (const gchar *pstr)
{
	GString *res;
	gunichar unich;
	gchar *p, *str;

	if (pstr == NULL)
		return NULL;

	str = e_util_utf8_remove_accents (pstr);
	if (!str)
		return NULL;

	res = g_string_new ("");

	for (p = e_util_unicode_get_utf8 (str, &unich); p && unich; p = e_util_unicode_get_utf8 (p, &unich)) {
		g_string_append_unichar (res, g_unichar_tolower (unich));
	}

	g_free (str);

	/* it was invalid unichar string */
	if (p == NULL) {
		g_string_free (res, TRUE);
		return NULL;
	}

	return res;
}
static gboolean
exists_helper (const gchar *ps1,
               const gchar *ps2,
               const gchar *region)
{
	gboolean res = FALSE;
	gchar *s1 = e_util_utf8_remove_accents (ps1);
	gchar *s2 = e_util_utf8_remove_accents (ps2);

	if (e_util_utf8_strstrcase (s1, s2))
		res = TRUE;

	g_free (s1);
	g_free (s2);

	return res;
}
static gboolean
beginswith_helper (const gchar *ps1,
                   const gchar *ps2,
                   const gchar *region)
{
	gchar *p;
	gboolean res = FALSE;
	gchar *s1 = e_util_utf8_remove_accents (ps1);
	gchar *s2 = e_util_utf8_remove_accents (ps2);

	if ((p = (gchar *) e_util_utf8_strstrcase (s1, s2))
	    && (p == s1))
		res = TRUE;

	g_free (s1);
	g_free (s2);

	return res;
}
static gboolean
is_helper (const gchar *ps1,
           const gchar *ps2,
           const gchar *region)
{
	gchar *s1, *s2;
	gboolean res = FALSE;

	s1 = e_util_utf8_remove_accents (ps1);
	s2 = e_util_utf8_remove_accents (ps2);

	if (!e_util_utf8_strcasecmp (s1, s2))
		res = TRUE;

	g_free (s1);
	g_free (s2);

	return res;
}
static gchar *
beginswith_helper (const gchar *ps1,
                   const gchar *ps2)
{
	gchar *p, *res;
	gchar *s1 = e_util_utf8_remove_accents (ps1);
	gchar *s2 = e_util_utf8_remove_accents (ps2);

	if ((p = (gchar *) e_util_utf8_strstrcase (s1, s2))
	    && (p == s1))
		res = (gchar *) ps1;
	else
		res = NULL;

	g_free (s1);
	g_free (s2);

	return res;
}
static gchar *
is_helper (const gchar *ps1,
           const gchar *ps2)
{
	gchar *s1, *s2, *res;

	s1 = e_util_utf8_remove_accents (ps1);
	s2 = e_util_utf8_remove_accents (ps2);

	if (!e_util_utf8_strcasecmp (s1, s2))
		res = (gchar *) ps1;
	else
		res = NULL;

	g_free (s1);
	g_free (s2);

	return res;
}
static gchar *
endswith_helper (const gchar *ps1,
                 const gchar *ps2)
{
	gchar *s1 = e_util_utf8_remove_accents (ps1);
	gchar *s2 = e_util_utf8_remove_accents (ps2);
	gchar *res;
	glong s1len = g_utf8_strlen (s1, -1);
	glong s2len = g_utf8_strlen (s2, -1);

	if (s1len < s2len)
		res = NULL;
	else
		res = (gchar *) e_util_utf8_strstrcase (g_utf8_offset_to_pointer (s1, s1len - s2len), s2);

	g_free (s1);
	g_free (s2);

	return res;
}