4 int xread(int fd
, void *buf
, int len
)
8 while ((r
= read(fd
, buf
+ n
, len
- n
)) > 0)
13 int xwrite(int fd
, void *buf
, int len
)
17 while ((w
= write(fd
, buf
+ n
, len
- n
)) > 0)
22 static int readutf8(char **src
)
27 while (l
< 6 && (unsigned char) *s
& (0x40 >> l
))
29 result
= (0x3f >> l
) & (unsigned char) *s
++;
31 result
= (result
<< 6) | ((unsigned char) *s
++ & 0x3f);
36 void utf8_dec(int *dst
, char *src
)
41 if (!(~(unsigned char) *s
& 0xc0))
49 static void writeutf8(char **dst
, int c
)
54 *d
++ = 0xf0 | (c
>> 18);
56 } else if (c
> 0x7ff) {
57 *d
++ = 0xe0 | (c
>> 12);
59 } else if (c
> 0x7f) {
60 *d
++ = 0xc0 | (c
>> 6);
64 *d
++ = 0x80 | (c
>> (l
* 6)) & 0x3f;
68 void utf8_enc(char *dst
, int *src
)