sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

utftorunestr.c (427B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "../utf.h"
      3 
      4 size_t
      5 utftorunestr(const char *str, Rune *r)
      6 {
      7 	size_t i;
      8 	int n;
      9 
     10 	for (i = 0; (n = chartorune(&r[i], str)) && r[i]; i++)
     11 		str += n;
     12 
     13 	return i;
     14 }
     15 
     16 size_t
     17 utfntorunestr(const char *str, size_t len, Rune *r)
     18 {
     19 	size_t i;
     20 	int n;
     21 	const char *end = str + len;
     22 
     23 	for (i = 0; (n = charntorune(&r[i], str, end - str)); i++)
     24 		str += n;
     25 
     26 	return i;
     27 }