aboutsummaryrefslogtreecommitdiff
path: root/src/libbio/bputrune.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libbio/bputrune.c')
-rw-r--r--src/libbio/bputrune.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libbio/bputrune.c b/src/libbio/bputrune.c
new file mode 100644
index 00000000..a2eaa83e
--- /dev/null
+++ b/src/libbio/bputrune.c
@@ -0,0 +1,23 @@
+#include "lib9.h"
+#include <bio.h>
+#include <utf.h>
+
+int
+Bputrune(Biobuf *bp, long c)
+{
+ Rune rune;
+ char str[4];
+ 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;
+}