Blob
1 #include <u.h>2 #include <libc.h>3 #include <bin.h>4 #include <httpd.h>6 int7 hurlfmt(Fmt *f)8 {9 char buf[HMaxWord*2];10 Rune r;11 char *s;12 int t;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 else22 buf[t++] = r;23 }24 buf[t] = 0;25 return fmtstrcpy(f, buf);26 }