12 fprint(2, "%s [ -h ] [ -c charset ] [ file ]\n", argv0);
21 while(strchr("\t ", *s))
24 if(*s == '"' || *s == '\'')
31 if(*e == '-' || *e == '_')
36 return smprint("%.*s", (int)(e-s), s);
41 main(int argc, char *argv[])
43 int pfd[2], pflag = 0;
50 cset = EARGF(usage());
59 if(open(*argv, OREAD) != 1)
62 if((nbuf = read(0, buf, sizeof(buf)-1)) < 0)
66 /* useless BOM marker */
67 if(memcmp(buf, "\xEF\xBB\xBF", 3)==0)
68 memmove(buf, buf+3, nbuf-3);
71 if(s = cistrstr(buf, "encoding="))
76 if(s = cistrstr(buf, "charset="))
97 switch(rfork(RFFDG|RFREND|RFPROC|RFNOWAIT)){
107 arg[2] = smprint("{tcs -f %s | tcs -f html} || cat", cset);
109 exec("/bin/rc", arg);
117 if(write(1, buf, nbuf) != nbuf)
118 sysfatal("write: %r");
119 if((nbuf = read(0, buf, sizeof(buf))) < 0)
120 sysfatal("read: %r");