shithub: riscv

ref: 3869d7a8437e2a9902529cd68915dddcb43e6782
dir: /sys/src/libbio/bputrune.c/

View raw version
#include	<u.h>
#include	<libc.h>
#include	<bio.h>

int
Bputrune(Biobufhdr *bp, long c)
{
	Rune rune;
	char str[UTFmax];
	int n;

	rune = c;
	if(rune < Runeself) {
		Bputc(bp, rune);
		return 1;
	}
	n = runetochar(str, &rune);
	if(n == 0)
		return Bbad;
	if(Bwrite(bp, str, n) != n)
		return Beof;
	return n;
}