Darshit Shah <[email protected]> writes:
> Yes, I guess I'm looking for UTF-8 strings, because other character
> encodings wouldn't create this problem, (I think?)
> I'll look at the Wiki page again and see of GNULib has anything, Right
> now, I'm trying to implement a solution based on wide characters
> through wchar.h but I don't like the code I've written. I's prefer
> something more elegant and efficient.
have you had a look at the mbiter module of gnulib? Its documentation
says that you can turn:
char *iter;
for (iter = buf; iter < buf + buflen; iter++)
{
do_something (*iter);
}
into:
mbi_iterator_t iter;
for (mbi_init (iter, buf, buflen); mbi_avail (iter); mbi_advance
(iter))
{
do_something (mbi_cur_ptr (iter), mb_len (mbi_cur (iter)));
}
and seems quite straightforward to me.
Regards,
Giuseppe