> This should work (untested):
>
> int findFirstNCharacters(const char *str, int n)
> {
>  int bytes = 0;
>  int maxBytes = strlen(str);
>  while (n>0 != *str!=0) {
>    int bytesInChar = fl_utf_nb_char(*str, maxBytes);
>    if (bytesInChar==-1) break; // error in UTF-8
>    bytes += bytesInChar;
>    maxBytes -= bytesInChar;
>    str += bytesInChar;
>    n--;
>  }
>  return bytes;
> }

Thank you for this clue!
I suppose you meant something like "int bytesInChar =
fl_utf8len1(*str)" instead the " = fl_utf_nb_char(*str, maxBytes)",
aren't ?
Anyhow I made function which works as I want. I won't try to suggest
to add it to fl_draw(), but such function would be a good helper to
use with fl_draw() as Ian said before.

Nikita Egorov

PS Though it seems to me fl_draw(s,n,x,y) is a function that gives
confusing results and it needs thorough docs at least.

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to