| ---
turlfmt.c (425B)
---
1 #include
2 #include
3 #include
4 #include
5
6 int
7 hurlfmt(Fmt *f)
8 {
9 char buf[HMaxWord*2];
10 Rune r;
11 char *s;
12 int t;
13
14 s = va_arg(f->args, char*);
15 for(t = 0; t < sizeof(buf) - 8; ){
16 s += chartorune(&r, s);
17 if(r == 0)
18 break;
19 if(r <= ' ' || r == '%' || r >= Runeself)
20 t += snprint(&buf[t], sizeof(buf)-t, "%%%2.2x", r);
21 else
22 buf[t++] = r;
23 }
24 buf[t] = 0;
25 return fmtstrcpy(f, buf);
26 } |