bputrune.c - 9base - revived minimalist port of Plan 9 userland to Unix
 (HTM) git clone git://git.suckless.org/9base
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       bputrune.c (309B)
       ---
            1 #include        "lib9.h"
            2 #include        <bio.h>
            3 #include        <utf.h>
            4 
            5 int
            6 Bputrune(Biobuf *bp, long c)
            7 {
            8         Rune rune;
            9         char str[UTFmax];
           10         int n;
           11 
           12         rune = c;
           13         if(rune < Runeself) {
           14                 Bputc(bp, rune);
           15                 return 1;
           16         }
           17         n = runetochar(str, &rune);
           18         if(n == 0)
           19                 return Bbad;
           20         if(Bwrite(bp, str, n) != n)
           21                 return Beof;
           22         return n;
           23 }