Pádraig Brady wrote: > I would suggest a new function due to the > way I see this function called most often. > > /* definitely not sure of this name */ > uint8_t * > u8_str_u8_chr (const uint8_t *s, const uint8_t *c, size_t size) > { > switch (size): > { > case 1: > return (uint8_t *) strchr ((const char *) s, *c); > case 2: > //use logic from current u8_strchr() > case 3: > ... > case 4: > ... > } > } > ... > while ((f=u8_str_u8_chr (s, "–", 3));
Such an API does not appear very robust to me: it is quite easy to mistakenly pass a string consisting of more or less than 1 character as second argument. If the argument to be searched for is given as an UTF-8 string rather than as an ucs4_t, I would better recommend to use the u8_strstr function. Bruno