code: 9ferno

ref: c11957a7915d355d80ff7e6a21721ba05441ca29
dir: /libbio/bputrune.c/

View raw version
#include	"lib9.h"
#include	<bio.h>

int
Bputrune(Biobuf *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;
}