int maildir_search_start_str_chset(struct maildir_searchengine *engine, const char *string, const char *chset) { #define SPC(s) ((s) == ' '|| (s) == '\t' || (s) == '\r' || (s) == '\n') unicode_char *ucptr; size_t ucsize; unicode_convert_handle_t h=unicode_convert_tou_init(chset, &ucptr, &ucsize, 1); size_t i, j; int rc; if (h == NULL) return -1; if (unicode_convert(h, string, strlen(string))) { unicode_convert_deinit(h, NULL); return -1; } if (unicode_convert_deinit(h, NULL)) return -1; for (i=j=0; ucptr[i]; ) { while (SPC(ucptr[i])) ++i; if (!ucptr[i]) break; while (ucptr[i]) { ucptr[j]=unicode_lc(ucptr[i]); ++j; if (SPC(ucptr[i])) break; ++i; } } while (j > 0 && SPC(ucptr[j-1])) --j; ucptr[j]=0; rc=maildir_search_start_unicode(engine, ucptr); free(ucptr); return rc; }
static char *tolower_func(const struct unicode_info *u, const char *cp, int *ip) { unicode_char *uc=unicode_utf8_tou(cp, ip), *p; char *s; if (!uc) return (0); for (p=uc; *p; p++) *p=unicode_lc(*p); s=unicode_utf8_fromu(uc, ip); free(uc); return (s); }
static char *tolower_func(const struct unicode_info *u, const char *cp, int *ip) { unicode_char *uc=c2u(u, cp, ip); char *s; int dummy; unsigned i; if (!uc) return (NULL); for (i=0; uc[i]; i++) { unicode_char c=unicode_lc(uc[i]); if (revlookup(c)) uc[i]=c; } s=u2c(u, uc, &dummy); free(uc); return (s); }