fputrune.c (467B)
1 /* See LICENSE file for copyright and license details. */ 2 #include <errno.h> 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <string.h> 6 7 #include "../utf.h" 8 9 int 10 fputrune(const Rune *r, FILE *fp) 11 { 12 char buf[UTFmax]; 13 14 return fwrite(buf, runetochar(buf, r), 1, fp); 15 } 16 17 int 18 efputrune(const Rune *r, FILE *fp, const char *file) 19 { 20 int ret; 21 22 if ((ret = fputrune(r, fp)) < 0) { 23 fprintf(stderr, "fputrune %s: %s\n", file, strerror(errno)); 24 exit(1); 25 } 26 return ret; 27 }