4 * Translate Unicode to HTML by asking tcs(1).
5 * This way we don't have yet another table.
12 static Rune **tcscache[256];
19 if(tcscache[r>>8] && tcscache[r>>8][r&0xFF])
20 return tcscache[r>>8][r&0xFF];
32 execl("tcs", "tcs", "-t", "html", nil);
41 fprint(fd, "%C\n", r);
42 q = Brdline(&b, '\n');
44 sysfatal("tcs: early eof");
45 q[Blinelen(&b)-1] = 0;
46 if(tcscache[r>>8] == nil)
47 tcscache[r>>8] = emalloc(256*sizeof tcscache[0][0]);
48 tcscache[r>>8][r&0xFF] = erunesmprint("%s", q);
49 return tcscache[r>>8][r&0xFF];
53 * Translate troff to Unicode by looking in troff's utfmap.
54 * This way we don't have yet another hard-coded table.
56 typedef struct Trtab Trtab;
63 static Trtab trtab[200];
66 static Trtab trinit[] =
79 char *file, *f[10], *p, s[3];
83 if(rs[0] >= Runeself || rs[1] >= Runeself)
89 for(i=0; i<nelem(trinit) && ntrtab < nelem(trtab); i++){
90 trtab[ntrtab] = trinit[i];
93 file = unsharp("#9/troff/font/devutf/utfmap");
94 if((b = Bopen(file, OREAD)) == nil)
95 sysfatal("open %s: %r", file);
96 while((p = Brdline(b, '\n')) != nil){
98 nf = getfields(p, f, nelem(f), 0, "\t");
99 for(i=0; i+2<=nf && ntrtab<nelem(trtab); i+=2){
100 chartorune(&trtab[ntrtab].r, f[i]);
101 memmove(trtab[ntrtab].t, f[i+1], 2);
107 if(ntrtab >= nelem(trtab))
108 fprint(2, "%s: trtab too small\n", argv0);
111 for(i=0; i<ntrtab; i++)
112 if(strcmp(s, trtab[i].t) == 0)