9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] utftex
@ 2002-05-14 20:11 paurea
  0 siblings, 0 replies; only message in thread
From: paurea @ 2002-05-14 20:11 UTC (permalink / raw)
  To: paurea, 9fans

[-- Attachment #1: Type: text/plain, Size: 42 bytes --]

Sorry for the other empty message...



[-- Attachment #2: utftex.c --]
[-- Type: text/plain, Size: 22712 bytes --]

/* mk clean mk install*/
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>

typedef struct Utab Utab;
struct Utab {
	char *latex;
	Rune r;
	int needspc;
};

Utab utab[] = {
         {"\\\'A",0x00c1,0},
         {"\\\'E",0x00c9,0},
         {"\\\'I",0x00cd,0},
         {"\\\'O",0x00d3,0},
         {"\\\'U",0x00da,0},
         {"\\\'a",0x00e1,0},
         {"\\\'e",0x00e9,0},
         {"\\\'i",0x00ed,0},
         {"\\\'o",0x00f3,0},
         {"\\\'u",0x00fa,0},
	{ "\\nobreakspace", 0x00a0,1},
	{ "\\textexclamdown", 0x00a1,1},
	{ "\\textcent", 0x00a2,1},
	{ "\\pounds", 0x00a3,1},
	{ "\\textcurrency", 0x00a4,1},
	{ "\\textyen", 0x00a5,1},
	{ "\\textbrokenbar", 0x00a6,1},
	{ "\\S", 0x00a7,1},
	{ "\\\"{}", 0x00a8 ,1},
	{ "\\copyright", 0x00a9,1},
	{ "\\mathordfeminine", 0x00aa,1},
	{ "\\guillemotleft", 0x00ab,1},
	{ "\\textlnot", 0x00ac,1},
	{ "\\-", 0x00ad,1},
	{ "\\textregistered", 0x00ae ,1},
	{ "\\textdegree", 0x00b0,1},
	{ "\\plusminus", 0x00b1,1},
	{ "\\texttwosuperior", 0x00b2 ,1},
	{ "\\textthreesuperior", 0x00b3 ,1},
	{ "\\mu", 0x00b5 ,1},
	{ "\\P", 0x00b6 ,1},
	{ "\\periodcentered", 0x00b7,1},
	{ "\\textonesuperior", 0x00b9 ,1},
	{ "\\textordmasculine", 0x00ba ,1},
	{ "\\guillemotright", 0x00bb ,1},
	{ "\\frac14", 0x00bc,1},
	{ "\\frac12", 0x00bd ,1},
	{ "\\frac34", 0x00be ,1},
	{ "\\textquestiondown", 0x00bf ,1},
	{ "\\^A", 0x00c2 ,0},
	{ "\\~A", 0x00c3 ,0},
	{ "\\\"A", 0x00c4 ,0},
	{ "\\AA", 0x00c5,0},
	{ "\\AE", 0x00c6 ,0},
	{ "\\c C", 0x00c7,0},
	{ "\\^E", 0x00ca ,0},
	{ "\\\"E", 0x00cb ,0},
	{ "\\^I", 0x00ce ,0},
	{ "\\\"I", 0x00cf ,0},
	{ "\\DH", 0x00d0 ,1},
	{ "\\~N", 0x00d1 ,0},
	{ "\\^O", 0x00d4 ,0},
	{ "\\~O", 0x00d5 ,0},
	{ "\\\"O", 0x00d6 ,0},
	{ "\\texttimes", 0x00d7,1},
	{ "\\O", 0x00d8 ,0},
	{ "\\^U", 0x00db ,0},
	{ "\\\"U", 0x00dc,0},
	{ "\\TH", 0x00de,1},
	{ "\\ss", 0x00df,1},
	{ "\\^a", 0x00e2,0},
	{ "\\~a", 0x00e3,0},
	{ "\\\"a", 0x00e4,0},
	{ "\\aa", 0x00e5 ,1},
	{ "\\ae", 0x00e6 ,1},
	{ "\\c c", 0x00e7,1 },
	{ "\\^e", 0x00ea ,0},
	{ "\\\"e", 0x00eb,0},
	{ "\\^\\i", 0x00ee ,0},
	{ "\\\"\\i", 0x00ef ,0},
	{ "\\dh", 0x00f0 ,0},
	{ "\\~n", 0x00f1 ,0},
	{ "\\^o", 0x00f4 ,0},
	{ "\\~o", 0x00f5 ,0},
	{ "\\\"o", 0x00f6 ,0},
	{ "\\textdiv", 0x00f7 ,0},
	{ "\\o", 0x00f8 ,0},
	{ "\\^u", 0x00fb ,0},
	{ "\\\"u", 0x00fc ,0},
	{ "\\th", 0x00fe ,0},
	{ "\\\"y", 0x00ff ,0},
	{ "\\u A", 0x0102 ,0},
	{ "\\u a", 0x0103 ,0},
	{ "\\k A", 0x0104 ,0},
	{ "\\k a", 0x0105 ,0},
	{ "\\^C", 0x0108 ,0},
	{ "\\^c", 0x0109 ,0},
	{ "\\.C", 0x010a ,0},
	{ "\\.c", 0x010b ,0},
	{ "\\v C", 0x010c ,0},
	{ "\\v c", 0x010d ,0},
	{ "\\v D", 0x010e ,0},
	{ "\\v d", 0x010f ,0},
	{ "\\DH", 0x0110 ,0},
	{ "\\dh", 0x0111 ,0},
	{ "\\u E", 0x0114 ,0},
	{ "\\u e", 0x0115 ,0},
	{ "\\.E", 0x0116 ,0},
	{ "\\.e", 0x0117 ,0},
	{ "\\k E", 0x0118 ,0},
	{ "\\k e", 0x0119 ,0},
	{ "\\v E", 0x011a ,0},
	{ "\\v e", 0x011b ,0},
	{ "\\^G", 0x011c ,0},
	{ "\\^g", 0x011d ,0},
	{ "\\u G", 0x011e ,0},
	{ "\\u g", 0x011f ,0},
	{ "\\.G", 0x0120 ,0},
	{ "\\.g", 0x0121 ,0},
	{ "\\c G", 0x0122 ,0},
	{ "\\^H", 0x0124 ,0},
	{ "\\^h", 0x0125 ,0},
	{ "\\~I", 0x0128 ,0},
	{ "\\~\\i", 0x0129 ,0},
	{ "\\u I", 0x012c ,0},
	{ "\\u\\i", 0x012d ,0},
	{ "\\c I", 0x012e ,0},
	{ "\\c i", 0x012f ,0},
	{ "\\.I", 0x0130 ,0},
	{ "\\i", 0x0131 ,0},
	{ "\\^J", 0x0134 ,0},
	{ "\\^j", 0x0135 ,0},
	{ "\\c K", 0x0136 ,0},
	{ "\\c k", 0x0137 ,0},
	{ "\\c L", 0x013b ,0},
	{ "\\c l", 0x013c ,0},
	{ "\\v L", 0x013d ,0},
	{ "\\v l", 0x013e ,0},
	{ "\\L", 0x0141 ,0},
	{ "\\l", 0x0142 ,0},
	{ "\\c N", 0x0145 ,0},
	{ "\\c n", 0x0146 ,0},
	{ "\\v N", 0x0147 ,0},
	{ "\\v n", 0x0148 ,0},
	{ "\\NG", 0x014a ,0},
	{ "\\ng", 0x014b ,0},
	{ "\\u O", 0x014e ,0},
	{ "\\u o", 0x014f ,0},
	{ "\\H O", 0x0150 ,0},
	{ "\\H o", 0x0151 ,0},
	{ "\\OE", 0x0152 ,0},
	{ "\\oe", 0x0153 ,0},
	{ "\\c R", 0x0156 ,0},
	{ "\\c r", 0x0157 ,0},
	{ "\\v R", 0x0158 ,0},
	{ "\\v r", 0x0159 ,0},
	{ "\\^S", 0x015c ,0},
	{ "\\^s", 0x015d ,0},
	{ "\\c S", 0x015e ,0},
	{ "\\c s", 0x015f ,0},
	{ "\\v S", 0x0160 ,0},
	{ "\\v s", 0x0161 ,0},
	{ "\\c T", 0x0162 ,0},
	{ "\\c t", 0x0163 ,0},
	{ "\\v T", 0x0164 ,0},
	{ "\\v t", 0x0165 ,0},
	{ "\\~U", 0x0168 ,0},
	{ "\\~u", 0x0169 ,0},
	{ "\\u U", 0x016c ,0},
	{ "\\u u", 0x016d ,0},
	{ "\\r U", 0x016e ,0},
	{ "\\r u", 0x016f ,0},
	{ "\\H U", 0x0170 ,0},
	{ "\\H u", 0x0171 ,0},
	{ "\\^W", 0x0174 ,0},
	{ "\\^w", 0x0175 ,0},
	{ "\\^Y", 0x0176 ,0},
	{ "\\^y", 0x0177 ,0},
	{ "\\\"Y", 0x0178 ,0},
	{ "\\.Z", 0x017b ,0},
	{ "\\.z", 0x017c ,0},
	{ "\\v Z", 0x017d ,0},
	{ "\\v A", 0x01cd ,0},
	{ "\\v a", 0x01ce ,0},
	{ "\\v I", 0x01cf ,0},
	{ "\\v\\i", 0x01d0 ,0},
	{ "\\v O", 0x01d1 ,0},
	{ "\\v o", 0x01d2 ,0},
	{ "\\v U", 0x01d3 ,0},
	{ "\\v u", 0x01d4 ,0},
	{ "\\v{\\\"U}", 0x01d9 ,1},
	{ "\\v{\\\"u}", 0x01da ,1},
	{ "\\v G", 0x01e6 ,0},
	{ "\\v g", 0x01e7 ,0},
	{ "\\v K", 0x01e8 ,0},
	{ "\\v k", 0x01e9 ,0},
	{ "\\k O", 0x01ea ,0},
	{ "\\k o", 0x01eb ,0},
	{ "\\ipa{0}", 0x0250,1},
	{ "\\ipa{1}", 0x0251,1},
	{ "\\ipa{2}", 0x0252,1},
	{ "\\ipa{8}", 0x0253,1},
	{ "\\ipa{61}", 0x0254,1},
	{ "\\ipa{11}", 0x0255,1},
	{ "\\ipa{17}", 0x0256,1},
	{ "\\ipa{16}", 0x0257,1},
	{ "\\ipa{23}", 0x0258,1},
	{ "\\ipa{21}", 0x0259,1},
	{ "\\ipa{22}", 0x025a,1},
	{ "\\ipa{24}", 0x025b,1},
	{ "\\ipa{25}", 0x025c,1},
	{ "\\ipa{26}", 0x025d,1},
	{ "\\ipa{26}", 0x025e,1},
	{ "\\ipa{44}", 0x025f,1},
	{ "\\ipa{29}", 0x0260,1},
	{ "\\ipa{28}", 0x0261,1},
	{ "\\ipa{30}", 0x0262,1},
	{ "\\ipa{32}", 0x0263,1},
	{ "\\ipa{33}", 0x0264,1},
	{ "\\ipa{38}", 0x0265,1},
	{ "\\ipa{36}", 0x0266,1},
	{ "\\ipa{37}", 0x0267,1},
	{ "\\ipa{39}", 0x0268,1},
	{ "\\ipa{41}", 0x0269,1},
	{ "\\ipa{42}", 0x026a,1},
	{ "\\ipa{45}", 0x026b,1},
	{ "\\ipa{47}", 0x026c,1},
	{ "\\ipa{48}", 0x026d,1},
	{ "\\ipa{49}", 0x026e,1},
	{ "\\ipa{53}", 0x026f,1},
	{ "\\ipa{54}", 0x0270,1},
	{ "\\ipa{52}", 0x0271,1},
	{ "\\ipa{55}", 0x0272,1},
	{ "\\ipa{57}", 0x0273,1},
	{ "\\ipa{58}", 0x0274,1},
	{ "\\ipa{60}", 0x0275,1},
	{ "\\ipa{63}", 0x0277,1},
	{ "\\ipa{67}", 0x0278,1},
	{ "\\ipa{71}", 0x0279,1},
	{ "\\ipa{73}", 0x027a,1},
	{ "\\ipa{72}", 0x027b,1},
	{ "\\ipa{69}", 0x027c,1},
	{ "\\ipa{70}", 0x027d,1},
	{ "\\ipa{68}", 0x027e,1},
	{ "\\ipa{74}", 0x0280,1},
	{ "\\ipa{75}", 0x0281,1},
	{ "\\ipa{76}", 0x0282,1},
	{ "\\ipa{77}", 0x0283,1},
	{ "\\ipa{78}", 0x0286,1},
	{ "\\ipa{82}", 0x0287,1},
	{ "\\ipa{80}", 0x0288,1},
	{ "\\ipa{84}", 0x0289,1},
	{ "\\ipa{86}", 0x028a,1},
	{ "\\ipa{89}", 0x028b,1},
	{ "\\ipa{4}", 0x028c,1},
	{ "\\ipa{90}", 0x028d,1},
	{ "\\ipa{92}", 0x028e,1},
	{ "\\ipa{93}", 0x028f,1},
	{ "\\ipa{95}", 0x0290,1},
	{ "\\ipa{94}", 0x0291,1},
	{ "\\ipa{96}", 0x0292,1},
	{ "\\ipa{97}", 0x0293,1},
	{ "\\ipa{98}", 0x0294,1},
	{ "\\ipa{99}", 0x0295,1},
	{ "\\ipa{100}", 0x0296,1},
	{ "\\ipa{12}", 0x0297,1},
	{ "\\ipa{59}", 0x0298,1},
	{ "\\ipa{27}", 0x029a,1},
	{ "\\ipa{18}", 0x02a4,1},
	{ "\\ipa{81}", 0x02a7,1},
	{ "\\ipa{101}", 0x02c0,1},
	{ "\\ipa{118}", 0x02c2,1},
	{ "\\ipa{119}", 0x02c3,1},
	{ "\\ipa{116}", 0x02c4,1},
	{ "\\ipa{117}", 0x02c5,1},
	{ "\\ipa{104}", 0x02c8,1},
	{ "\\ipa{105}", 0x02cc,1},
	{ "\\ipa{113}", 0x02d0,1},
	{ "\\ipa{112}", 0x02d1,1},
	{ "\\ipa{122}", 0x02d3,1},
	{ "\\ipa{108}", 0x02d4,1},
	{ "\\ipa{109}", 0x02d5,1},
	{ "\\ipa{120}", 0x02da,1},
	{ "\\ipa{126}", 0x02db,1},
	{ "\\ipa{102}", 0x02e4,1},
	{ "\\Gamma", 0x0393,1},
	{ "\\Delta", 0x0394,1},
	{ "\\Theta", 0x0398,1},
	{ "\\Lambda", 0x039b,1},
	{ "\\Xi", 0x039e,1},
	{ "\\Pi", 0x03a0,1},
	{ "\\Sigma", 0x03a3,1},
	{ "\\Upsilon", 0x03a5,1},
	{ "\\Phi", 0x03a6,1},
	{ "\\Chi", 0x03a7,1},
	{ "\\Psi", 0x03a8,1},
	{ "\\Omega", 0x03a9,1},
	{ "\\beta", 0x03b2,1},
	{ "\\gamma", 0x03b3,1},
	{ "\\delta", 0x03b4,1},
	{ "\\epsilon", 0x03b5,1},
	{ "\\zeta", 0x03b6,1},
	{ "\\eta", 0x03b7,1},
	{ "\\theta", 0x03b8,1},
	{ "\\iota", 0x03b9,1},
	{ "\\kappa", 0x03ba,1},
	{ "\\lambda", 0x03bb,1},
	{ "\\mu", 0x03bc,1},
	{ "\\nu", 0x03bd,1},
	{ "\\xi", 0x03be,1},
	{ "\\pi", 0x03c0,1},
	{ "\\rho", 0x03c1,1},
	{ "\\varsigma", 0x03c2,1},
	{ "\\sigma", 0x03c3,1},
	{ "\\tau", 0x03c4,1},
	{ "\\upsilon", 0x03c5,1},
	{ "\\phi", 0x03c6,1},
	{ "\\chi", 0x03c7,1},
	{ "\\psi", 0x03c8,1},
	{ "\\omega", 0x03c9,1},
	{ "\\vartheta", 0x03d1,1},
	{ "\\varphi", 0x03d5,1},
	{ "\\cyrillic{\\char 19}", 0x0401,0},
	{ "\\cyrillic{\\char6}", 0x0402,0},
	{ "\\cyrillic{\\accent38 G}", 0x0403,0},
	{ "\\cyrillic{\\char5}", 0x0404,0},
	{ "\\cyrillic{\\char22}", 0x0405,0},
	{ "\\cyrillic{\\char4}", 0x0406,0},
	{ "\\cyrillic{\\accent32{\\char4}}", 0x0407,0},
	{ "\\cyrillic{J}", 0x0408,0},
	{ "\\cyrillic{\\char1}", 0x0409,0},
	{ "\\cyrillic{\\char0}", 0x040a,0},
	{ "\\cyrillic{\\char7}", 0x040b,0},
	{ "\\cyrillic{\\accent22 K}", 0x040c,0},
	{ "\\cyrillic{\\char45}", 0x040d,0},
	{ "\\cyrillic{\\accent64 U}", 0x040e,0},
	{ "\\cyrillic{\\char2}", 0x040f,0},
	{ "\\cyrillic{A}", 0x0410,0},
	{ "\\cyrillic{B}", 0x0411,0},
	{ "\\cyrillic{V}", 0x0412,0},
	{ "\\cyrillic{G}", 0x0413,0},
	{ "\\cyrillic{D}", 0x0414,0},
	{ "\\cyrillic{E}", 0x0415,0},
	{ "\\cyrillic{\\char17}", 0x0416,0},
	{ "\\cyrillic{Z}", 0x0417,0},
	{ "\\cyrillic{I}", 0x0418,0},
	{ "\\cyrillic{\\char18}", 0x0419,0},
	{ "\\cyrillic{K}", 0x041a,0},
	{ "\\cyrillic{L}", 0x041b,0},
	{ "\\cyrillic{M}", 0x041c,0},
	{ "\\cyrillic{N}", 0x041d,0},
	{ "\\cyrillic{O}", 0x041e,0},
	{ "\\cyrillic{P}", 0x041f,0},
	{ "\\cyrillic{R}", 0x0420,0},
	{ "\\cyrillic{S}", 0x0421,0},
	{ "\\cyrillic{T}", 0x0422,0},
	{ "\\cyrillic{U}", 0x0423,0},
	{ "\\cyrillic{F}", 0x0424,0},
	{ "\\cyrillic{H}", 0x0425,0},
	{ "\\cyrillic{C}", 0x0426,0},
	{ "\\cyrillic{Q}", 0x0427,0},
	{ "\\cyrillic{X}", 0x0428,0},
	{ "\\cyrillic{W}", 0x0429,0},
	{ "\\cyrillic{\\char95}", 0x042a,0},
	{ "\\cyrillic{Y}", 0x042b,0},
	{ "\\cyrillic{\\char94}", 0x042c,0},
	{ "\\cyrillic{\\char3}", 0x042d,0},
	{ "\\cyrillic{\\char16}", 0x042e,0},
	{ "\\cyrillic{\\char23}", 0x042f,0},
	{ "\\cyrillic{a}", 0x0430,0},
	{ "\\cyrillic{b}", 0x0431,0},
	{ "\\cyrillic{v}", 0x0432,0},
	{ "\\cyrillic{g}", 0x0433,0},
	{ "\\cyrillic{d}", 0x0434,0},
	{ "\\cyrillic{e}", 0x0435,0},
	{ "\\cyrillic{\\char25}", 0x0436,0},
	{ "\\cyrillic{z}", 0x0437,0},
	{ "\\cyrillic{i}", 0x0438,0},
	{ "\\cyrillic{\\char26}", 0x0439,0},
	{ "\\cyrillic{k}", 0x043a,0},
	{ "\\cyrillic{l}", 0x043b,0},
	{ "\\cyrillic{m}", 0x043c,0},
	{ "\\cyrillic{n}", 0x043d,0},
	{ "\\cyrillic{o}", 0x043e,0},
	{ "\\cyrillic{r}", 0x0440,0},
	{ "\\cyrillic{s}", 0x0441,0},
	{ "\\cyrillic{t}", 0x0442,0},
	{ "\\cyrillic{u}", 0x0443,0},
	{ "\\cyrillic{f}", 0x0444,0},
	{ "\\cyrillic{h}", 0x0445,0},
	{ "\\cyrillic{c}", 0x0446,0},
	{ "\\cyrillic{q}", 0x0447,0},
	{ "\\cyrillic{x}", 0x0448,0},
	{ "\\cyrillic{w}", 0x0449,0},
	{ "\\cyrillic{\\char127}", 0x044a,0},
	{ "\\cyrillic{y}", 0x044b,0},
	{ "\\cyrillic{\\char126}", 0x044c,0},
	{ "\\cyrillic{\\char11}", 0x044d,0},
	{ "\\cyrillic{\\char24}", 0x044e,0},
	{ "\\cyrillic{\\char31}", 0x044f,0},
	{ "\\cyrillic{}", 0x0450,0},
	{ "\\cyrillic{\\char27}", 0x0451,0},
	{ "\\cyrillic{\\char14}", 0x0452,0},
	{ "\\cyrillic{\\accent38 g}", 0x0453,0},
	{ "\\cyrillic{\\char13}", 0x0454,0},
	{ "\\cyrillic{\\char30}", 0x0455,0},
	{ "\\cyrillic{\\char12}", 0x0456,0},
	{ "\\cyrillic{\\accent32{\\char12}}", 0x0457,0},
	{ "\\cyrillic{j}", 0x0458,0},
	{ "\\cyrillic{\\char9}", 0x0459,0},
	{ "\\cyrillic{\\char8}", 0x045a,0},
	{ "\\cyrillic{\\char15}", 0x045b,0},
	{ "\\cyrillic{\\accent38 k}", 0x045c,0},
	{ "\\S", 0x045d ,1},
	{ "\\cyrillic{\\accent64 u}", 0x045e,0},
	{ "\\cyrillic{\\char10}", 0x045f,0},
	{ "\\cyrillic{\\char21}", 0x0472,0},
	{ "\\cyrillic{\\char29}", 0x0473,0},
	{ "\\cyrillic{\\char20}", 0x0474,0},
	{ "\\textcompwordmark", 0x200b ,1},
	{ "\\textendash", 0x2012,1},
	{ "\\textendash", 0x2013,1},
	{ "\\textemdash", 0x2014,1},
	{ "\\textemdash", 0x2015,1},
	{ "\\textquoteleft", 0x2018,1},
	{ "\\textquoteright", 0x2019,1},
	{ "\\quotesinglbase", 0x201a,1},
	{ "\\textquoteleft", 0x201b,1},
	{ "\\textquotedbleft", 0x201c,1},
	{ "\\textquotedbright", 0x201d,1},
	{ "\\quotedblbase", 0x201e,1},
	{ "\\textquoteleft", 0x201f,1},
	{ "\\dag", 0x2020,1},
	{ "\\ddag", 0x2021,1},
	{ "\\textbullet", 0x2022,1},
	{ "\\dots", 0x2026,1},
	{ "\\textperiodcentered", 0x2027,1},
	{ "\\mathbb C", 0x2102,1},
	{ "\\Game", 0x210a,1},
	{ "\\mathbb H", 0x210d,1},
	{ "\\hslash", 0x210f,1},
	{ "\\mathscr I", 0x2110,1},
	{ "\\mathscr L", 0x2112,1},
	{ "\\mathbb N", 0x2115,1},
	{ "\\mathbb P", 0x2119,1},
	{ "\\mathbb Q", 0x211a,1},
	{ "\\mathscr R", 0x211b,1},
	{ "\\mathbb R", 0x211d,1},
	{ "\\texttrademark", 0x2122,1},
	{ "\\mathbb Z", 0x2124,1},
	{ "\\mho", 0x2127,1},
	{ "\\mathscr B", 0x212c,1},
	{ "\\mathscr E", 0x2130,1},
	{ "\\mathscr F", 0x2131,1},
	{ "\\Finv", 0x2132,1},
	{ "\\aleph", 0x2135,1},
	{ "\\beth", 0x2136,1},
	{ "\\gimel", 0x2137,1},
	{ "\\daleth", 0x2138,1},
	{ "\\leftarrow", 0x2190,1},
	{ "\\uparrow", 0x2191,1},
	{ "\\rightarrow", 0x2192,1},
	{ "\\downarrow", 0x2193,1},
	{ "\\leftrightarrow", 0x2194,1},
	{ "\\updownarrow", 0x2195,1},
	{ "\\nwarrow", 0x2196,1},
	{ "\\nearrow", 0x2197,1},
	{ "\\searrow", 0x2198,1},
	{ "\\swarrow", 0x2199,1},
	{ "\\nleftarrow", 0x219a,1},
	{ "\\nrightarrow", 0x219b,1},
	{ "\\leadsfrom", 0x219c,1},
	{ "\\leadsto", 0x219d,1},
	{ "\\twoheadleftarrow", 0x219e,1},
	{ "\\twoheadrightarrow", 0x21a0,1},
	{ "\\leftarrowtail", 0x21a2,1},
	{ "\\rightarrowtail", 0x21a3,1},
	{ "\\mapsto", 0x21a6,1},
	{ "\\hookleftarrow", 0x21a9,1},
	{ "\\hookrightarrow", 0x21aa,1},
	{ "\\loopleftarrow", 0x21ab,1},
	{ "\\looprightarrow", 0x21ac,1},
	{ "\\leftrightsquigarrow", 0x21ad,1},
	{ "\\nleftrightarrow", 0x21ae,1},
	{ "\\Lsh", 0x21b0,1},
	{ "\\Rsh", 0x21b1,1},
	{ "\\curvearrowleft", 0x21b6,1},
	{ "\\curvearrowright", 0x21b7,1},
	{ "\\circlearrowleft", 0x21ba,1},
	{ "\\circlearrowright", 0x21bb,1},
	{ "\\leftharpoonup", 0x21bc,1},
	{ "\\leftharpoondown", 0x21bd,1},
	{ "\\upharpoonright", 0x21be,1},
	{ "\\rightharpoonup", 0x21c0,1},
	{ "\\rightharpoondown", 0x21c1,1},
	{ "\\downharpoonright", 0x21c2,1},
	{ "\\downharpoonleft", 0x21c3,1},
	{ "\\rightleftarrows", 0x21c4,1},
	{ "\\leftrightarrows", 0x21c6,1},
	{ "\\leftleftarrows", 0x21c7,1},
	{ "\\upuparrows", 0x21c8,1},
	{ "\\rightrightarrows", 0x21c9,1},
	{ "\\downdownarrows", 0x21ca,1},
	{ "\\leftrightharpoons", 0x21cb,1},
	{ "\\rightleftharpoons", 0x21cc,1},
	{ "\\not\\Leftarrow", 0x21cd,1},
	{ "\\not\\Leftrightarrow", 0x21ce,1},
	{ "\\not\\Rightarrow", 0x21cf,1},
	{ "\\Leftarrow", 0x21d0,1},
	{ "\\Uparrow", 0x21d1,1},
	{ "\\Rightarrow", 0x21d2,1},
	{ "\\Downarrow", 0x21d3,1},
	{ "\\Leftrightarrow", 0x21d4,1},
	{ "\\Updownarrow", 0x21d5,1},
	{ "\\Lleftarrow", 0x21da,1},
	{ "\\Rrightarrow", 0x21db,1},
	{ "\\leftsquigarrow", 0x21dc,1},
	{ "\\rightsquigarrow", 0x21dd,1},
	{ "\\dashleftarrow", 0x21e0,1},
	{ "\\dashuparrow", 0x21e1,1},
	{ "\\dashrightarrow", 0x21e2,1},
	{ "\\dashdownarrow", 0x21e3,1},
	{ "\\forall", 0x2200,1},
	{ "\\complement", 0x2201,1},
	{ "\\partial", 0x2202,1},
	{ "\\exists", 0x2203,1},
	{ "\\nexists", 0x2204,1},
	{ "\\emptyset", 0x2205,1},
	{ "\\Delta", 0x2206,1},
	{ "\\nabla", 0x2207,1},
	{ "\\in", 0x2208,1},
	{ "\\notin", 0x2209,1},
	{ "\\epsilon", 0x220a,1},
	{ "\\ni", 0x220b,1},
	{ "\\notni", 0x220c,1},
	{ "\\prod", 0x220f,1},
	{ "\\coprod", 0x2210,1},
	{ "\\sum", 0x2211,1},
	{ "\\mp", 0x2213,1},
	{ "\\dotplus", 0x2214,1},
	{ "\\setminus", 0x2216,1},
	{ "\\ast", 0x2217,1},
	{ "\\circ", 0x2218,1},
	{ "\\bullet", 0x2219,1},
	{ "\\surd", 0x221a,1},
	{ "\\root 3 \\of{}", 0x221b,1},
	{ "\\root 4 \\of{}", 0x221c,1},
	{ "\\propto", 0x221d,1},
	{ "\\infty", 0x221e,1},
	{ "\\angle", 0x2220,1},
	{ "\\measuredangle", 0x2221,1},
	{ "\\sphericalangle", 0x2222,1},
	{ "\\mid", 0x2223,1},
	{ "\\not\\mid", 0x2224,1},
	{ "\\parallel", 0x2225,1},
	{ "\\not\\parallel", 0x2226,1},
	{ "\\wedge", 0x2227,1},
	{ "\\vee", 0x2228,1},
	{ "\\cap", 0x2229,1},
	{ "\\cup", 0x222a,1},
	{ "\\int\\int\\int", 0x222d,1},
	{ "\\int\\int", 0x222c,1},
	{ "\\int", 0x222b,1},
	{ "\\oint\\oint\\oint", 0x2230,1},
	{ "\\oint\\oint", 0x222f,1},
	{ "\\oint", 0x222e,1},
	{ "\\therefore", 0x2234,1},
	{ "\\because", 0x2235,1},
	{ "\\sim", 0x223c,1},
	{ "\\backsim", 0x223d,1},
	{ "\\wr", 0x2240,1},
	{ "\\notsim", 0x2241,1},
	{ "\\eqsim", 0x2242,1},
	{ "\\simeq", 0x2243,1},
	{ "\\notsimeq", 0x2244,1},
	{ "\\cong", 0x2245,1},
	{ "\\notcong", 0x2247,1},
	{ "\\approx", 0x2248,1},
	{ "\\notapprox", 0x2249,1},
	{ "\\approxeq", 0x224a,1},
	{ "\\asymp", 0x224d,1},
	{ "\\Bumpeq", 0x224e,1},
	{ "\\bumpeq", 0x224f,1},
	{ "\\doteq", 0x2250,1},
	{ "\\doteqdot", 0x2251,1},
	{ "\\fallingdotseq", 0x2252,1},
	{ "\\risingdotseq", 0x2253,1},
	{ "\\circeq", 0x2257,1},
	{ "\\triangleq", 0x225c,1},
	{ "\\defineequal", 0x225d,1},
	{ "\\neq", 0x2260,1},
	{ "\\not=", 0x2260,1},
	{ "\\equiv", 0x2261,1},
	{ "\\notequiv", 0x2262,1},
	{ "\\not\\equiv", 0x2262,1},
	{ "\\leq", 0x2264,1},
	{ "\\geq", 0x2265,1},
	{ "\\leqq", 0x2266,1},
	{ "\\geqq", 0x2267,1},
	{ "\\lneqq", 0x2268,1},
	{ "\\gneqq", 0x2269,1},
	{ "\\ll", 0x226a,1},
	{ "\\gg", 0x226b,1},
	{ "\\between", 0x226c,1},
	{ "\\notasymp", 0x226d,1},
	{ "\\notless", 0x226e,1},
	{ "\\not<", 0x226e,1},
	{ "\\notgreater", 0x226f,1},
	{ "\\not>", 0x226f,1},
	{ "\\nleqslant", 0x2270,1},
	{ "\\ngeqslant", 0x2271,1},
	{ "\\lesssim", 0x2272,1},
	{ "\\gtrsim", 0x2273,1},
	{ "\\not\\lesssim", 0x2274,1},
	{ "\\not\\gtrsim", 0x2275,1},
	{ "\\not\\lessgtr", 0x2276,1},
	{ "\\not\\gtrless", 0x2277,1},
	{ "\\prec", 0x227a,1},
	{ "\\succ", 0x227b,1},
	{ "\\preceq", 0x227c,1},
	{ "\\succeq", 0x227d,1},
	{ "\\precsim", 0x227e,1},
	{ "\\notprec", 0x2280,1},
	{ "\\notsucc", 0x2281,1},
	{ "\\subset", 0x2282,1},
	{ "\\supset", 0x2283,1},
	{ "\\notsubset", 0x2284,1},
	{ "\\notsupset", 0x2285,1},
	{ "\\subseteq", 0x2286,1},
	{ "\\supseteq", 0x2287,1},
	{ "\\not\\subseteq", 0x2288,1},
	{ "\\not\\supseteq", 0x2289,1},
	{ "\\varsubsetneq", 0x228a,1},
	{ "\\varsupsetneq", 0x228b,1},
	{ "\\uplus", 0x228e,1},
	{ "\\sqsubset", 0x228f,1},
	{ "\\sqsupset", 0x2290,1},
	{ "\\sqsubseteq", 0x2291,1},
	{ "\\sqsupseteq", 0x2292,1},
	{ "\\sqcap", 0x2293,1},
	{ "\\sqcup", 0x2294,1},
	{ "\\oplus", 0x2295,1},
	{ "\\ominus", 0x2296,1},
	{ "\\otimes", 0x2297,1},
	{ "\\oslash", 0x2298,1},
	{ "\\odot", 0x2299,1},
	{ "\\circledcirc", 0x229a,1},
	{ "\\circledast", 0x229b,1},
	{ "\\circleddash", 0x229d,1},
	{ "\\boxplus", 0x229e,1},
	{ "\\boxminus", 0x229f,1},
	{ "\\boxtimes", 0x22a0,1},
	{ "\\boxdot", 0x22a1,1},
	{ "\\vdash", 0x22a2,1},
	{ "\\dashv", 0x22a3,1},
	{ "\\top", 0x22a4,1},
	{ "\\bot", 0x22a5,1},
	{ "\\vdash", 0x22a6,1},
	{ "\\models", 0x22a7,1},
	{ "\\vDash", 0x22a8,1},
	{ "\\Vdash", 0x22a9,1},
	{ "\\Vvdash", 0x22aa,1},
	{ "\\notvdash", 0x22ac,1},
	{ "\\notmodels", 0x22ad,1},
	{ "\\nVdash", 0x22ae,1},
	{ "\\nVDash", 0x22af,1},
	{ "\\triangleleft", 0x22b2,1},
	{ "\\triangleright", 0x22b3,1},
	{ "\\original", 0x22b6,1},
	{ "\\image", 0x22b7,1},
	{ "\\multimap", 0x22b8,1},
	{ "\\intercal", 0x22ba,1},
	{ "\\bigwedge", 0x22c0,1},
	{ "\\bigvee", 0x22c1,1},
	{ "\\bigcap", 0x22c2,1},
	{ "\\bigcup", 0x22c3,1},
	{ "\\diamond", 0x22c4,1},
	{ "\\cdot", 0x22c5,1},
	{ "\\star", 0x22c6,1},
	{ "\\divideontimes", 0x22c7,1},
	{ "\\bowtie", 0x22c8,1},
	{ "\\ltimes", 0x22c9,1},
	{ "\\rtimes", 0x22ca,1},
	{ "\\leftthreetimes", 0x22cb,1},
	{ "\\rightthreetimes", 0x22cc,1},
	{ "\\backsimeq", 0x22cd,1},
	{ "\\curlyvee", 0x22ce,1},
	{ "\\curlywedge", 0x22cf,1},
	{ "\\Subset", 0x22d0,1},
	{ "\\Supset", 0x22d1,1},
	{ "\\Cap", 0x22d2,1},
	{ "\\Cup", 0x22d3,1},
	{ "\\pitchfork", 0x22d4,1},
	{ "\\lessdot", 0x22d6,1},
	{ "\\gtrdot", 0x22d7,1},
	{ "\\lll", 0x22d8,1},
	{ "\\ggg", 0x22d9,1},
	{ "\\lesseqgtr", 0x22da,1},
	{ "\\gtreqless", 0x22db,1},
	{ "\\lneq", 0x22dc,1},
	{ "\\gneq", 0x22dd,1},
	{ "\\curlyeqprec", 0x22de,1},
	{ "\\curlyeqsucc", 0x22df,1},
	{ "\\npreceq", 0x22e0,1},
	{ "\\nsucceq", 0x22e1,1},
	{ "\\notsqsubseteq", 0x22e2,1},
	{ "\\notsqsupseteq", 0x22e3,1},
	{ "\\lnsim", 0x22e6,1},
	{ "\\gnsim", 0x22e7,1},
	{ "\\precnsim", 0x22e8,1},
	{ "\\succnsim", 0x22e9,1},
	{ "\\ntriangleleft", 0x22ea,1},
	{ "\\ntriangleright", 0x22eb,1},
	{ "\\ntrianglelefteq", 0x22ec,1},
	{ "\\ntrianglerighteq", 0x22ed,1},
	{ "\\vdots", 0x22ee,1},
	{ "\\cdots", 0x22ef,1},
	{ "\\diagup", 0x22f0,1},
	{ "\\lceil", 0x2308,1},
	{ "\\rceil", 0x2309,1},
	{ "\\lfloor", 0x230a,1},
	{ "\\rfloor", 0x230b,1},
	{ "\\frown", 0x2322,1},
	{ "\\smile", 0x2323,1},
	{ "\\langle", 0x2329,1},
	{ "\\rangle", 0x232a,1},
};

void
utf2tex(Biobuf *bin, Biobuf *bout)
{
	int i, needspace;
	long l;
	Rune r;

	needspace = 0;
	while((l = Bgetrune(bin)) >= 0) {
		r = l;
		for(i=0; i<nelem(utab); i++)
			if(utab[i].r == r) {
				Bprint(bout, "%s", utab[i].latex);
				needspace = utab[i].needspc;
		//		Bprint(bout,"needspace:%d\n",needspace);
				break;
			}
		if(i == nelem(utab)) {
			if(needspace && r < 0x80 && isalpha(r))
				Bputc(bout, ' ');
			needspace = 0;
			Bputrune(bout, r);
		}
	}
}

int
replace(char *s, char *find, Rune repl)
{
	char *p, *e, *ee;
	char buf[1024];

Refind:
	p = strstr(s, find);
	if(p == nil)
		return 0;

	e = p + strlen(find);
	if(*e < 0x80 && isalpha(*e)) {
		s = e;
		goto Refind;
	}
	for(ee=e; *ee < 0x80 && isspace(*ee); ee++)
		;
	if(isalpha(*ee))
		e = ee;

	sprint(buf, "%C%s", repl, e);
	sprint(p, "%s", buf);
	return 1;
}

void
tex2utf(Biobuf *bin, Biobuf *bout)
{
	char *line;
	int i;

	while(line = Brdline(bin, '\n')) {
		line[Blinelen(bin)-1] = '\0';
		for(i=0; i<nelem(utab); i++)
			while(replace(line, utab[i].latex, utab[i].r))
				;
		Bprint(bout, "%s\n", line);
	}
}

void
main(int argc, char **argv)
{
	Biobuf bin, bout, *b;
	int i;
	void (*translate)(Biobuf*, Biobuf*);

	translate = utf2tex;
	ARGBEGIN{
	case 'u':
		translate = tex2utf;
		break;
	default:
		fprint(2, "usage: utftex [-u] [files...]\n");
		exits("usage");
	}ARGEND

	Binit(&bout, 1, OWRITE);
	if(argc == 0) {
		Binit(&bin, 0, OREAD);
		translate(&bin, &bout);
	} else {
		for(i=0; i<argc; i++) {
			b = Bopen(argv[i], OREAD);
			if(b == nil)
				fprint(2, "warning: cannot open \"%s\": %r\n", argv[i]);
			else
				translate(b, &bout);
		}
	}
	Bterm(&bout);
	exits(0);
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-05-14 20:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-14 20:11 [9fans] utftex paurea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).