sbase/libutf/fputrune.c
FRIGN 7c578bf5b0 Scrap writerune(), introducing fputrune()
Interface and function as proposed by cls.
Code is also shorter, everything else analogous to fgetrune().
2015-02-11 20:58:00 +01:00

28 lines
467 B
C

/* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../utf.h"
int
fputrune(const Rune *r, FILE *fp)
{
char buf[UTFmax];
return fwrite(buf, runetochar(buf, r), 1, fp);
}
int
efputrune(const Rune *r, FILE *fp, const char *file)
{
int ret;
if ((ret = fputrune(r, fp)) < 0) {
fprintf(stderr, "fputrune %s: %s\n", file, strerror(errno));
exit(1);
}
return ret;
}