2011-03-30 05:46:40 -07:00
|
|
|
#include <u.h>
|
|
|
|
#include <libc.h>
|
|
|
|
#include <bio.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
Bputrune(Biobufhdr *bp, long c)
|
|
|
|
{
|
|
|
|
Rune rune;
|
2012-12-31 12:09:46 -08:00
|
|
|
char str[UTFmax];
|
2011-03-30 05:46:40 -07:00
|
|
|
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;
|
|
|
|
}
|