Пример #1
0
static gboolean
mcview_ismark (const WView * view, int c)
{
#ifdef HAVE_CHARSET
    if (view->utf8)
        return g_unichar_ismark (c);
#else
    (void) view;
    (void) c;
#endif /* HAVE_CHARSET */
    return FALSE;
}
Пример #2
0
static char*
process_str (const char *str, gboolean xapian_esc, gboolean query_esc)
{
	GString *gstr;
	char *norm, *cur;
	gboolean is_field, is_range_field;

	norm = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
	if (G_UNLIKELY(!norm)) {  /* not valid utf8? */
		char *u8;
		u8 = mu_str_utf8ify (str);
		norm = g_utf8_normalize (u8, -1, G_NORMALIZE_ALL);
		g_free (u8);
	}

 	if (!norm)
		return NULL;

	/* msg-id needs some special care in queries */
	if (query_esc && is_msgid_field (str))
		return mu_str_process_msgid (str, TRUE);

	check_for_field (str, &is_field, &is_range_field);
	gstr = g_string_sized_new (strlen (norm));

	for (cur = norm; cur && *cur; cur = g_utf8_next_char (cur)) {

		gunichar uc;
		uc = g_utf8_get_char (cur);
		if (xapian_esc)
			if (handle_esc_maybe (gstr, &cur, uc, query_esc,
					      is_range_field))
				continue;

		if (g_unichar_ismark(uc))
			continue;

		if (!is_range_field)
			uc = g_unichar_tolower (uc);
		
		g_string_append_unichar (gstr, uc);
	}

	g_free (norm);
	return g_string_free (gstr, FALSE);
}
Пример #3
0
static gchar *
prepare_cmp_string (const gchar *str)
{
	GString *string;
	gchar *ptr, *tmp1, *tmp2;

	/* lower case */
	tmp1 = g_utf8_strdown (str, -1);
	
	/* normalize */
	tmp2 = g_utf8_normalize (tmp1, -1, G_NORMALIZE_DEFAULT);
	g_free (tmp1);

	/* remove accents */
	string = g_string_new ("");
	for (ptr = tmp2; *ptr; ptr = g_utf8_next_char (ptr)) {
		gunichar uc;
		uc = g_utf8_get_char (ptr);
		if (! g_unichar_ismark (uc))
			g_string_append_unichar (string, uc);
	}
	return g_string_free (string, FALSE);
}