Re: [dev] Re: [libutf] Proposal for additional rune utility functions
On Tue, Feb 10, 2015 at 10:07:52PM +0000, Connor Lane Smith wrote:
> int
> utftorunestr(const char *s, Rune *p)
> {
> int i, n;
>
> for(i = 0; (n = chartorune(&p[i], s)), p[i] != 0; i++)
> s += n;
> return i;
> }
>
> int
> fgetrune(Rune *p, FILE *fp)
> {
> char buf[UTFmax];
> int c, i = 0;
>
> do {
> if((c = fgetc(fp)) == EOF)
> break;
> buf[i++] = c;
> } while(!fullrune(buf, i));
>
> if(i == 0)
> return EOF;
>
> return charntorune(p, buf, i);
> }
>
> int
> fputrune(const Rune *p, FILE *fp)
> {
> char buf[UTFmax];
>
> return fwrite(buf, runetochar(buf, p), 1, fp);
> }
Very nice!
Received on Wed Feb 11 2015 - 01:24:12 CET
This archive was generated by hypermail 2.3.0
: Wed Feb 11 2015 - 01:36:07 CET