Browse Source

Plan 9 from Bell Labs 2006-01-28

David du Colombier 18 years ago
parent
commit
cea4c6c1a6
76 changed files with 7134 additions and 1017 deletions
  1. 78 43
      dist/replica/_plan9.db
  2. 76 39
      dist/replica/plan9.db
  3. 77 0
      dist/replica/plan9.log
  4. 1 2
      rc/bin/9fs
  5. 5 2
      sys/doc/8½/8½.ms
  6. 1 0
      sys/doc/9.ms
  7. 4 1
      sys/doc/acid.ms
  8. 1 0
      sys/doc/acidpaper.ms
  9. 17 5
      sys/doc/acme/acme.ms
  10. 1 0
      sys/doc/ape.ms
  11. 101 0
      sys/doc/asm.ms
  12. 4 1
      sys/doc/auth.ms
  13. 1 0
      sys/doc/comp.ms
  14. 1 0
      sys/doc/compiler.ms
  15. 46 31
      sys/doc/contents.ms
  16. 1 0
      sys/doc/fossil.ms
  17. 1 0
      sys/doc/fs/p0
  18. 1 0
      sys/doc/il/il.ms
  19. 1 0
      sys/doc/lexnames.ms
  20. 1 0
      sys/doc/libmach.ms
  21. 1 0
      sys/doc/mk.ms
  22. 92 204
      sys/doc/mkfile
  23. 1 0
      sys/doc/mkfiles.ms
  24. 1 0
      sys/doc/names.ms
  25. 1 0
      sys/doc/net/net.ms
  26. 3 0
      sys/doc/plumb.ms
  27. 1 0
      sys/doc/port.ms
  28. 1 0
      sys/doc/prog4.ms
  29. 1 0
      sys/doc/rc.ms
  30. 1 0
      sys/doc/release3.ms
  31. 1 0
      sys/doc/release4.ms
  32. 9 4
      sys/doc/sam/sam.ms
  33. 1 0
      sys/doc/sleep.ms
  34. 1 0
      sys/doc/spin.ms
  35. 1 0
      sys/doc/utf.ms
  36. 94 0
      sys/lib/tmac/tmac.html
  37. 7 2
      sys/lib/tmac/tmac.s
  38. 119 0
      sys/man/1/htmlroff
  39. 6 0
      sys/man/1/tcs
  40. 358 0
      sys/man/6/htmlroff
  41. 105 0
      sys/man/6/mhtml
  42. 148 0
      sys/src/cmd/htmlroff/a.h
  43. 116 0
      sys/src/cmd/htmlroff/char.c
  44. 287 0
      sys/src/cmd/htmlroff/html.c
  45. 241 0
      sys/src/cmd/htmlroff/input.c
  46. 72 0
      sys/src/cmd/htmlroff/main.c
  47. 38 0
      sys/src/cmd/htmlroff/mkfile
  48. 750 0
      sys/src/cmd/htmlroff/roff.c
  49. 186 0
      sys/src/cmd/htmlroff/t1.c
  50. 140 0
      sys/src/cmd/htmlroff/t10.c
  51. 107 0
      sys/src/cmd/htmlroff/t11.c
  52. 67 0
      sys/src/cmd/htmlroff/t12.c
  53. 17 0
      sys/src/cmd/htmlroff/t13.c
  54. 33 0
      sys/src/cmd/htmlroff/t14.c
  55. 13 0
      sys/src/cmd/htmlroff/t15.c
  56. 156 0
      sys/src/cmd/htmlroff/t16.c
  57. 131 0
      sys/src/cmd/htmlroff/t17.c
  58. 68 0
      sys/src/cmd/htmlroff/t18.c
  59. 142 0
      sys/src/cmd/htmlroff/t19.c
  60. 274 0
      sys/src/cmd/htmlroff/t2.c
  61. 79 0
      sys/src/cmd/htmlroff/t20.c
  62. 49 0
      sys/src/cmd/htmlroff/t3.c
  63. 142 0
      sys/src/cmd/htmlroff/t4.c
  64. 110 0
      sys/src/cmd/htmlroff/t5.c
  65. 74 0
      sys/src/cmd/htmlroff/t6.c
  66. 543 0
      sys/src/cmd/htmlroff/t7.c
  67. 449 0
      sys/src/cmd/htmlroff/t8.c
  68. 6 0
      sys/src/cmd/htmlroff/t9.c
  69. 123 0
      sys/src/cmd/htmlroff/util.c
  70. 275 0
      sys/src/cmd/tcs/8859.h
  71. 0 27
      sys/src/cmd/tcs/cyrillic.h
  72. 1 1
      sys/src/cmd/tcs/html.c
  73. 304 0
      sys/src/cmd/tcs/misc.h
  74. 3 0
      sys/src/cmd/tcs/mkfile
  75. 737 0
      sys/src/cmd/tcs/ms.h
  76. 29 655
      sys/src/cmd/tcs/tcs.c

+ 78 - 43
dist/replica/_plan9.db

@@ -273,6 +273,7 @@
 386/bin/hoc - 775 sys sys 1135570817 99860
 386/bin/html2ms - 775 sys sys 1135570817 66078
 386/bin/htmlfmt - 775 sys sys 1135570817 160781
+386/bin/htmlroff - 775 sys sys 1138406772 148065
 386/bin/ico - 775 sys sys 1135570818 161740
 386/bin/iconv - 775 sys sys 1135570818 113279
 386/bin/idiff - 775 sys sys 1135570818 76099
@@ -417,7 +418,7 @@
 386/bin/tail - 775 sys sys 1135570847 66163
 386/bin/tar - 775 sys sys 1135570847 93423
 386/bin/tbl - 775 sys sys 1131302431 113308
-386/bin/tcs - 775 sys sys 1130384340 256598
+386/bin/tcs - 775 sys sys 1138393253 309719
 386/bin/tee - 775 sys sys 1130384340 38446
 386/bin/telco - 775 sys sys 1134389878 103347
 386/bin/telnet - 775 sys sys 1135570847 80400
@@ -5391,7 +5392,7 @@ power/mkfile - 664 sys sys 948141304 46
 rc - 20000000775 sys sys 944959447 0
 rc/bin - 20000000775 sys sys 1018637942 0
 rc/bin/9fat: - 775 sys sys 1133179689 367
-rc/bin/9fs - 775 sys sys 1138240042 1027
+rc/bin/9fs - 775 sys sys 1138385380 986
 rc/bin/B - 775 sys sys 945617206 645
 rc/bin/C - 775 sys sys 1127395076 855
 rc/bin/Kill - 775 sys sys 1018637942 115
@@ -5592,48 +5593,48 @@ sparc64/mkfile - 664 sys sys 1114458667 46
 sys - 20000000775 sys sys 952648870 0
 sys/doc - 20000000775 sys sys 1018471272 0
 sys/doc/8½ - 20000000775 sys sys 945616779 0
-sys/doc/8½/8½.ms - 664 sys sys 1020895859 31593
+sys/doc/8½/8½.ms - 664 sys sys 1138396551 31721
 sys/doc/8½/8½.ps - 664 sys sys 1020895860 797150
 sys/doc/8½/fig1.ps - 664 sys sys 1020895859 473747
 sys/doc/8½/mkfile - 664 sys sys 1020895860 215
-sys/doc/9.ms - 664 sys sys 953237044 84632
+sys/doc/9.ms - 664 sys sys 1138396402 84662
 sys/doc/9.ps - 664 sys sys 960837924 508340
-sys/doc/acid.ms - 664 sys sys 1127411211 65062
+sys/doc/acid.ms - 664 sys sys 1138396403 65160
 sys/doc/acid.ps - 664 sys sys 1015012454 426359
-sys/doc/acidpaper.ms - 664 sys sys 952880777 44805
+sys/doc/acidpaper.ms - 664 sys sys 1138396403 44851
 sys/doc/acidpaper.ps - 664 sys sys 960837913 359639
 sys/doc/acme - 20000000775 sys sys 945616779 0
 sys/doc/acme/acme.fig1 - 664 sys sys 944959632 164559
 sys/doc/acme/acme.fig2 - 664 sys sys 944959632 56026
-sys/doc/acme/acme.ms - 664 sys sys 952880782 49851
+sys/doc/acme/acme.ms - 664 sys sys 1138396552 50028
 sys/doc/acme/acme.pdf - 664 sys sys 1020384351 117006
 sys/doc/acme/acme.ps - 664 sys sys 960837907 611301
 sys/doc/acme/bs - 664 sys sys 944959634 556
 sys/doc/acme/mkfile - 664 sys sys 961259926 304
-sys/doc/ape.ms - 664 sys sys 953344517 12595
+sys/doc/ape.ms - 664 sys sys 1138396403 12637
 sys/doc/ape.ps - 664 sys sys 960837914 258779
-sys/doc/asm.ms - 664 sys sys 958247686 28542
+sys/doc/asm.ms - 664 sys sys 1138396403 31516
 sys/doc/asm.ps - 664 sys sys 960837915 322051
-sys/doc/auth.ms - 664 sys sys 1021579975 66803
+sys/doc/auth.ms - 664 sys sys 1138396404 66854
 sys/doc/auth.ps - 664 sys sys 1021579976 451672
 sys/doc/cleanps - 775 sys sys 961259933 184
 sys/doc/colophon.ps - 664 sys sys 960837922 214122
-sys/doc/comp.ms - 664 sys sys 954266992 37792
+sys/doc/comp.ms - 664 sys sys 1138396405 37832
 sys/doc/comp.ps - 664 sys sys 960837915 345786
-sys/doc/compiler.ms - 664 sys sys 1067721142 30279
+sys/doc/compiler.ms - 664 sys sys 1138396405 30305
 sys/doc/compiler.ps - 664 sys sys 1091459054 309735
-sys/doc/contents.ms - 664 sys sys 1019916701 4920
+sys/doc/contents.ms - 664 sys sys 1138396405 5409
 sys/doc/contents.ps - 664 sys sys 1019916845 232629
 sys/doc/docfonts - 664 sys sys 1038117516 208
 sys/doc/fonts - 664 sys sys 944959649 137
-sys/doc/fossil.ms - 664 sys sys 1063856349 31400
+sys/doc/fossil.ms - 664 sys sys 1138396406 31439
 sys/doc/fossil.pdf - 664 sys sys 1042123169 63200
 sys/doc/fossil.ps - 664 sys sys 1135487951 313552
 sys/doc/fs - 20000000775 sys sys 945616779 0
 sys/doc/fs/fs.pdf - 664 sys sys 1020384351 47177
 sys/doc/fs/fs.ps - 664 sys sys 960837905 276918
 sys/doc/fs/mkfile - 664 sys sys 961259926 282
-sys/doc/fs/p0 - 664 sys sys 953844580 652
+sys/doc/fs/p0 - 664 sys sys 1138396562 682
 sys/doc/fs/p1 - 664 sys sys 953844581 989
 sys/doc/fs/p2 - 664 sys sys 953844581 3749
 sys/doc/fs/p3 - 664 sys sys 944959592 1475
@@ -5644,7 +5645,7 @@ sys/doc/fs/p7 - 664 sys sys 953844581 958
 sys/doc/fs/p8 - 664 sys sys 953844574 881
 sys/doc/fs/xx - 664 sys sys 944959592 65957
 sys/doc/il - 20000000775 sys sys 945616779 0
-sys/doc/il/il.ms - 664 sys sys 952880783 11367
+sys/doc/il/il.ms - 664 sys sys 1138396552 11390
 sys/doc/il/il.pdf - 664 sys sys 1020384351 44630
 sys/doc/il/il.ps - 664 sys sys 960837905 258028
 sys/doc/il/mkfile - 664 sys sys 961259927 214
@@ -5653,42 +5654,42 @@ sys/doc/il/transition.fig - 664 sys sys 944959591 15431
 sys/doc/il/transition.pic - 664 sys sys 944959591 11912
 sys/doc/il/xx - 664 sys sys 944959591 48924
 sys/doc/index.htm - 664 sys sys 1019916696 6906
-sys/doc/lexnames.ms - 664 sys sys 954383595 34046
+sys/doc/lexnames.ms - 664 sys sys 1138396406 34107
 sys/doc/lexnames.ps - 664 sys sys 960837909 335546
-sys/doc/libmach.ms - 664 sys sys 1021579974 24145
+sys/doc/libmach.ms - 664 sys sys 1138396406 24212
 sys/doc/libmach.ps - 664 sys sys 960837916 291283
 sys/doc/lp.ms - 664 sys sys 954614673 22366
 sys/doc/lp.ps - 664 sys sys 960837917 294399
-sys/doc/mk.ms - 664 sys sys 952880779 34413
+sys/doc/mk.ms - 664 sys sys 1138396445 34456
 sys/doc/mk.ps - 664 sys sys 960837917 329779
-sys/doc/mkfile - 664 sys sys 1091459055 4411
-sys/doc/mkfiles.ms - 664 sys sys 952880779 17888
+sys/doc/mkfile - 664 sys sys 1138396461 2393
+sys/doc/mkfiles.ms - 664 sys sys 1138396445 17910
 sys/doc/mkfiles.ps - 664 sys sys 960837918 269496
-sys/doc/names.ms - 664 sys sys 954269607 22103
+sys/doc/names.ms - 664 sys sys 1138396445 22143
 sys/doc/names.ps - 664 sys sys 960837918 288716
 sys/doc/net - 20000000775 sys sys 954033300 0
 sys/doc/net/mkfile - 664 sys sys 961259927 345
-sys/doc/net/net.ms - 664 sys sys 952880783 41191
+sys/doc/net/net.ms - 664 sys sys 1138396534 41237
 sys/doc/net/net.pdf - 664 sys sys 1020384351 82603
 sys/doc/net/net.ps - 664 sys sys 960837908 350053
 sys/doc/net/tree - 664 sys sys 944959636 866
 sys/doc/net/tree.pout - 664 sys sys 944959636 1755
 sys/doc/network.art - 664 sys sys 944959651 2260
 sys/doc/network.pic - 664 sys sys 944959651 4124
-sys/doc/plumb.ms - 664 sys sys 954383596 53250
+sys/doc/plumb.ms - 664 sys sys 1138396446 53312
 sys/doc/plumb.ps - 664 sys sys 960837910 391830
-sys/doc/port.ms - 664 sys sys 1020111393 16694
+sys/doc/port.ms - 664 sys sys 1138396446 16719
 sys/doc/port.ps - 664 sys sys 1020111394 268901
 sys/doc/preamble - 664 sys sys 961259497 203475
 sys/doc/prfile - 775 sys sys 944959668 3782
-sys/doc/prog4.ms - 664 sys sys 1019932830 16485
+sys/doc/prog4.ms - 664 sys sys 1138396446 16563
 sys/doc/prog4.ps - 664 sys sys 1019932831 271581
 sys/doc/ps - 664 sys sys 944959649 1739
-sys/doc/rc.ms - 664 sys sys 1063856321 34373
+sys/doc/rc.ms - 664 sys sys 1138396446 34404
 sys/doc/rc.ps - 664 sys sys 960837920 337955
-sys/doc/release3.ms - 664 sys sys 961261276 5492
+sys/doc/release3.ms - 664 sys sys 1138396446 5538
 sys/doc/release3.ps - 664 sys sys 961261277 230682
-sys/doc/release4.ms - 664 sys sys 1063856338 5160
+sys/doc/release4.ms - 664 sys sys 1138396446 5207
 sys/doc/release4.ps - 664 sys sys 1091459052 230868
 sys/doc/sam - 20000000775 sys sys 945617037 0
 sys/doc/sam/fig1.bm - 464 sys sys 944959645 42200
@@ -5704,20 +5705,20 @@ sys/doc/sam/fig6.pic - 464 sys sys 944959644 1105
 sys/doc/sam/fig7.pic - 464 sys sys 944959644 258
 sys/doc/sam/mkfile - 664 sys sys 961259927 574
 sys/doc/sam/refs - 464 sys sys 944959644 2652
-sys/doc/sam/sam.ms - 464 sys sys 954266468 94536
+sys/doc/sam/sam.ms - 464 sys sys 1138396552 94640
 sys/doc/sam/sam.pdf - 664 sys sys 1020384352 156123
 sys/doc/sam/sam.ps - 664 sys sys 960837910 707546
 sys/doc/sam/sam.tut - 464 sys sys 944959644 40481
-sys/doc/sleep.ms - 664 sys sys 953237030 15206
+sys/doc/sleep.ms - 664 sys sys 1138396447 15272
 sys/doc/sleep.ps - 664 sys sys 960837920 263882
-sys/doc/spin.ms - 664 sys sys 953344522 67475
+sys/doc/spin.ms - 664 sys sys 1138396447 67493
 sys/doc/spin.ps - 664 sys sys 960837923 443064
 sys/doc/title - 664 sys sys 1018974170 740
 sys/doc/title.ps - 664 sys sys 1018974170 214289
 sys/doc/trademarks.ps - 664 sys sys 960837912 217896
 sys/doc/troff.ms - 664 sys sys 953237047 120683
 sys/doc/troff.ps - 664 sys sys 1091459051 782310
-sys/doc/utf.ms - 664 sys sys 952880781 41659
+sys/doc/utf.ms - 664 sys sys 1138396447 41735
 sys/doc/utf.ps - 664 sys sys 960837922 363085
 sys/doc/venti - 20000000775 sys sys 1019852318 0
 sys/doc/venti/Block.gif - 664 sys sys 1019852315 3292
@@ -7036,6 +7037,7 @@ sys/lib/tmac/tmac.antimes - 664 sys sys 964454718 7809
 sys/lib/tmac/tmac.bits - 664 sys sys 944956202 1089
 sys/lib/tmac/tmac.cs - 664 sys sys 1112039298 21324
 sys/lib/tmac/tmac.e - 664 sys sys 964454711 11992
+sys/lib/tmac/tmac.html - 664 sys sys 1138396384 1950
 sys/lib/tmac/tmac.jsdisp - 664 sys sys 944956203 828
 sys/lib/tmac/tmac.m - 664 sys sys 944956203 87
 sys/lib/tmac/tmac.mcs - 664 sys sys 955115425 43067
@@ -7045,7 +7047,7 @@ sys/lib/tmac/tmac.pictures - 664 sys sys 944956203 4320
 sys/lib/tmac/tmac.psychrefs - 664 sys sys 944956203 608
 sys/lib/tmac/tmac.ptx - 664 sys sys 944956203 330
 sys/lib/tmac/tmac.rscover - 664 sys sys 944956203 2070
-sys/lib/tmac/tmac.s - 664 sys sys 1127393909 23027
+sys/lib/tmac/tmac.s - 664 sys sys 1138396381 23086
 sys/lib/tmac/tmac.scover - 664 sys sys 944956204 4616
 sys/lib/tmac/tmac.sdisp - 664 sys sys 944956204 864
 sys/lib/tmac/tmac.skeep - 664 sys sys 944956204 1346
@@ -7294,6 +7296,7 @@ sys/man/1/gzip - 664 sys sys 1124839836 3226
 sys/man/1/hget - 664 sys sys 1067722859 1483
 sys/man/1/history - 664 sys sys 1109685635 1709
 sys/man/1/hoc - 664 sys sys 1136378274 2357
+sys/man/1/htmlroff - 644 sys sys 1138396051 1831
 sys/man/1/idiff - 664 sys sys 1113743324 914
 sys/man/1/join - 664 sys sys 1113743324 2561
 sys/man/1/jpg - 664 sys sys 1113743325 4842
@@ -7360,7 +7363,7 @@ sys/man/1/syscall - 664 sys sys 1016466457 1439
 sys/man/1/tail - 664 sys sys 1113743327 1413
 sys/man/1/tar - 664 sys sys 1131884436 3439
 sys/man/1/tbl - 664 sys sys 944959674 4308
-sys/man/1/tcs - 664 sys sys 952627441 2575
+sys/man/1/tcs - 664 sys sys 1138383991 2682
 sys/man/1/tee - 664 sys sys 969499886 351
 sys/man/1/tel - 664 sys sys 1045501423 941
 sys/man/1/test - 664 sys sys 1079372544 3535
@@ -7407,7 +7410,7 @@ sys/man/2/auth - 664 sys sys 1017423719 7539
 sys/man/2/authsrv - 664 sys sys 1055734550 4145
 sys/man/2/bin - 664 sys sys 985023077 1880
 sys/man/2/bind - 664 sys sys 1015091518 4685
-sys/man/2/bio - 664 sys sys 1017423720 6538
+sys/man/2/bio - 664 sys sys 1138335268 6523
 sys/man/2/blowfish - 664 sys sys 1032058672 1280
 sys/man/2/brk - 664 sys sys 944959694 1179
 sys/man/2/cachechars - 664 sys sys 1082222350 7061
@@ -7637,11 +7640,13 @@ sys/man/6/authsrv - 664 sys sys 1128483124 13304
 sys/man/6/color - 664 sys sys 988225304 5181
 sys/man/6/face - 664 sys sys 1062505426 2846
 sys/man/6/font - 664 sys sys 1077594184 2528
+sys/man/6/htmlroff - 644 sys sys 1138396325 6608
 sys/man/6/image - 664 sys sys 988225304 6209
 sys/man/6/keyboard - 664 sys sys 1079575918 4418
 sys/man/6/keys.who - 664 sys sys 1110641163 775
 sys/man/6/man - 664 sys sys 944959678 4961
 sys/man/6/map - 664 sys sys 944959678 1892
+sys/man/6/mhtml - 644 sys sys 1138396055 1710
 sys/man/6/mpictures - 664 sys sys 944959678 2899
 sys/man/6/ms - 664 sys sys 958249504 6815
 sys/man/6/namespace - 664 sys sys 1048637182 1576
@@ -12228,6 +12233,35 @@ sys/src/cmd/htmlfmt/html.c - 664 sys sys 1060876449 6032
 sys/src/cmd/htmlfmt/main.c - 664 sys sys 1034015651 1108
 sys/src/cmd/htmlfmt/mkfile - 664 sys sys 1034015650 297
 sys/src/cmd/htmlfmt/util.c - 664 sys sys 1015364025 1765
+sys/src/cmd/htmlroff - 20000000775 sys sys 1138396082 0
+sys/src/cmd/htmlroff/a.h - 664 sys sys 1138396079 3200
+sys/src/cmd/htmlroff/char.c - 664 sys sys 1138396079 2178
+sys/src/cmd/htmlroff/html.c - 664 sys sys 1138396079 3991
+sys/src/cmd/htmlroff/input.c - 664 sys sys 1138396079 3147
+sys/src/cmd/htmlroff/main.c - 664 sys sys 1138396080 1065
+sys/src/cmd/htmlroff/mkfile - 664 sys sys 1138396082 330
+sys/src/cmd/htmlroff/roff.c - 664 sys sys 1138396080 10842
+sys/src/cmd/htmlroff/t1.c - 664 sys sys 1138396080 2816
+sys/src/cmd/htmlroff/t10.c - 664 sys sys 1138396080 1911
+sys/src/cmd/htmlroff/t11.c - 664 sys sys 1138396080 1200
+sys/src/cmd/htmlroff/t12.c - 664 sys sys 1138396080 600
+sys/src/cmd/htmlroff/t13.c - 664 sys sys 1138396080 210
+sys/src/cmd/htmlroff/t14.c - 664 sys sys 1138396080 561
+sys/src/cmd/htmlroff/t15.c - 664 sys sys 1138396080 138
+sys/src/cmd/htmlroff/t16.c - 664 sys sys 1138396080 2270
+sys/src/cmd/htmlroff/t17.c - 664 sys sys 1138396081 1711
+sys/src/cmd/htmlroff/t18.c - 664 sys sys 1138396081 1125
+sys/src/cmd/htmlroff/t19.c - 664 sys sys 1138396081 2353
+sys/src/cmd/htmlroff/t2.c - 664 sys sys 1138396081 4079
+sys/src/cmd/htmlroff/t20.c - 664 sys sys 1138396081 1025
+sys/src/cmd/htmlroff/t3.c - 664 sys sys 1138396081 851
+sys/src/cmd/htmlroff/t4.c - 664 sys sys 1138396081 1974
+sys/src/cmd/htmlroff/t5.c - 664 sys sys 1138396081 1749
+sys/src/cmd/htmlroff/t6.c - 664 sys sys 1138396081 1135
+sys/src/cmd/htmlroff/t7.c - 664 sys sys 1138396082 8626
+sys/src/cmd/htmlroff/t8.c - 664 sys sys 1138396082 6245
+sys/src/cmd/htmlroff/t9.c - 664 sys sys 1138396082 47
+sys/src/cmd/htmlroff/util.c - 664 sys sys 1138396082 1615
 sys/src/cmd/iconv.c - 664 sys sys 1039753035 1801
 sys/src/cmd/idiff.c - 664 sys sys 1014926695 6896
 sys/src/cmd/import.c - 664 sys sys 1133180705 7028
@@ -13299,6 +13333,7 @@ sys/src/cmd/tbl/tt.c - 664 sys sys 944961244 1708
 sys/src/cmd/tbl/tu.c - 664 sys sys 944961244 4817
 sys/src/cmd/tbl/tv.c - 664 sys sys 944961244 3329
 sys/src/cmd/tcs - 20000000775 sys sys 954034511 0
+sys/src/cmd/tcs/8859.h - 644 sys sys 1138382778 16466
 sys/src/cmd/tcs/big5.c - 664 sys sys 944961288 99606
 sys/src/cmd/tcs/big5.h - 664 sys sys 944961287 112
 sys/src/cmd/tcs/conv.h - 664 sys sys 1135487940 941
@@ -13306,7 +13341,7 @@ sys/src/cmd/tcs/conv_big5.c - 664 sys sys 944961288 2821
 sys/src/cmd/tcs/conv_gb.c - 664 sys sys 944961287 2210
 sys/src/cmd/tcs/conv_jis.c - 664 sys sys 944961289 10998
 sys/src/cmd/tcs/conv_ksc.c - 664 sys sys 944961288 2716
-sys/src/cmd/tcs/cyrillic.h - 664 sys sys 944961287 9508
+sys/src/cmd/tcs/cyrillic.h - 664 sys sys 1138382779 7921
 sys/src/cmd/tcs/desc.latin - 664 sys sys 944961287 20189
 sys/src/cmd/tcs/ex2.utf - 664 sys sys 944961288 14431
 sys/src/cmd/tcs/ex3.utf - 664 sys sys 944961288 807
@@ -13330,7 +13365,7 @@ sys/src/cmd/tcs/font/qbits.c - 664 sys sys 944961251 2037
 sys/src/cmd/tcs/gb.c - 664 sys sys 944961288 62707
 sys/src/cmd/tcs/gb.h - 664 sys sys 944961287 183
 sys/src/cmd/tcs/hdr.h - 664 sys sys 944961287 1213
-sys/src/cmd/tcs/html.c - 664 sys sys 1135958471 5247
+sys/src/cmd/tcs/html.c - 664 sys sys 1138381110 5244
 sys/src/cmd/tcs/jis.h - 664 sys sys 944961287 2873
 sys/src/cmd/tcs/ksc.c - 664 sys sys 944961289 72413
 sys/src/cmd/tcs/ksc.h - 664 sys sys 944961287 112
@@ -13338,9 +13373,11 @@ sys/src/cmd/tcs/kuten208.c - 664 sys sys 948046995 59960
 sys/src/cmd/tcs/kuten208.h - 664 sys sys 944961287 94
 sys/src/cmd/tcs/kuten212.c - 664 sys sys 944961289 55407
 sys/src/cmd/tcs/kuten212.h - 664 sys sys 944961287 94
-sys/src/cmd/tcs/mkfile - 664 sys sys 1135487940 542
+sys/src/cmd/tcs/misc.h - 644 sys sys 1138382780 19274
+sys/src/cmd/tcs/mkfile - 664 sys sys 1138382781 591
+sys/src/cmd/tcs/ms.h - 644 sys sys 1138382780 44069
 sys/src/cmd/tcs/plan9.h - 664 sys sys 944961287 751
-sys/src/cmd/tcs/tcs.c - 664 sys sys 1135487940 54089
+sys/src/cmd/tcs/tcs.c - 664 sys sys 1138382781 15489
 sys/src/cmd/tcs/utf.c - 664 sys sys 1125501123 7962
 sys/src/cmd/tee.c - 664 sys sys 954970286 1062
 sys/src/cmd/telco - 20000000775 sys sys 1015701205 0
@@ -13935,7 +13972,7 @@ sys/src/cmd/upas/ml/mlmgr.c - 664 sys sys 1045505888 2332
 sys/src/cmd/upas/ml/mlowner.c - 664 sys sys 1015096763 1142
 sys/src/cmd/upas/ned - 20000000775 sys sys 1015013194 0
 sys/src/cmd/upas/ned/mkfile - 664 sys sys 1060041738 233
-sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1136911937 44584
+sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1138335303 44583
 sys/src/cmd/upas/pop3 - 20000000775 sys sys 1015009816 0
 sys/src/cmd/upas/pop3/mkfile - 664 sys sys 1064589604 186
 sys/src/cmd/upas/pop3/pop3.c - 664 sys sys 1115039848 14327
@@ -15540,5 +15577,3 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
-sys/man/2/bio - 664 sys sys 1138335268 6523
-sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1138335303 44583

+ 76 - 39
dist/replica/plan9.db

@@ -273,6 +273,7 @@
 386/bin/hoc - 775 sys sys 1135570817 99860
 386/bin/html2ms - 775 sys sys 1135570817 66078
 386/bin/htmlfmt - 775 sys sys 1135570817 160781
+386/bin/htmlroff - 775 sys sys 1138406772 148065
 386/bin/ico - 775 sys sys 1135570818 161740
 386/bin/iconv - 775 sys sys 1135570818 113279
 386/bin/idiff - 775 sys sys 1135570818 76099
@@ -417,7 +418,7 @@
 386/bin/tail - 775 sys sys 1135570847 66163
 386/bin/tar - 775 sys sys 1135570847 93423
 386/bin/tbl - 775 sys sys 1131302431 113308
-386/bin/tcs - 775 sys sys 1130384340 256598
+386/bin/tcs - 775 sys sys 1138393253 309719
 386/bin/tee - 775 sys sys 1130384340 38446
 386/bin/telco - 775 sys sys 1134389878 103347
 386/bin/telnet - 775 sys sys 1135570847 80400
@@ -5391,7 +5392,7 @@ power/mkfile - 664 sys sys 948141304 46
 rc - 20000000775 sys sys 944959447 0
 rc/bin - 20000000775 sys sys 1018637942 0
 rc/bin/9fat: - 775 sys sys 1133179689 367
-rc/bin/9fs - 775 sys sys 1138240042 1027
+rc/bin/9fs - 775 sys sys 1138385380 986
 rc/bin/B - 775 sys sys 945617206 645
 rc/bin/C - 775 sys sys 1127395076 855
 rc/bin/Kill - 775 sys sys 1018637942 115
@@ -5592,48 +5593,48 @@ sparc64/mkfile - 664 sys sys 1114458667 46
 sys - 20000000775 sys sys 952648870 0
 sys/doc - 20000000775 sys sys 1018471272 0
 sys/doc/8½ - 20000000775 sys sys 945616779 0
-sys/doc/8½/8½.ms - 664 sys sys 1020895859 31593
+sys/doc/8½/8½.ms - 664 sys sys 1138396551 31721
 sys/doc/8½/8½.ps - 664 sys sys 1020895860 797150
 sys/doc/8½/fig1.ps - 664 sys sys 1020895859 473747
 sys/doc/8½/mkfile - 664 sys sys 1020895860 215
-sys/doc/9.ms - 664 sys sys 953237044 84632
+sys/doc/9.ms - 664 sys sys 1138396402 84662
 sys/doc/9.ps - 664 sys sys 960837924 508340
-sys/doc/acid.ms - 664 sys sys 1127411211 65062
+sys/doc/acid.ms - 664 sys sys 1138396403 65160
 sys/doc/acid.ps - 664 sys sys 1015012454 426359
-sys/doc/acidpaper.ms - 664 sys sys 952880777 44805
+sys/doc/acidpaper.ms - 664 sys sys 1138396403 44851
 sys/doc/acidpaper.ps - 664 sys sys 960837913 359639
 sys/doc/acme - 20000000775 sys sys 945616779 0
 sys/doc/acme/acme.fig1 - 664 sys sys 944959632 164559
 sys/doc/acme/acme.fig2 - 664 sys sys 944959632 56026
-sys/doc/acme/acme.ms - 664 sys sys 952880782 49851
+sys/doc/acme/acme.ms - 664 sys sys 1138396552 50028
 sys/doc/acme/acme.pdf - 664 sys sys 1020384351 117006
 sys/doc/acme/acme.ps - 664 sys sys 960837907 611301
 sys/doc/acme/bs - 664 sys sys 944959634 556
 sys/doc/acme/mkfile - 664 sys sys 961259926 304
-sys/doc/ape.ms - 664 sys sys 953344517 12595
+sys/doc/ape.ms - 664 sys sys 1138396403 12637
 sys/doc/ape.ps - 664 sys sys 960837914 258779
-sys/doc/asm.ms - 664 sys sys 958247686 28542
+sys/doc/asm.ms - 664 sys sys 1138396403 31516
 sys/doc/asm.ps - 664 sys sys 960837915 322051
-sys/doc/auth.ms - 664 sys sys 1021579975 66803
+sys/doc/auth.ms - 664 sys sys 1138396404 66854
 sys/doc/auth.ps - 664 sys sys 1021579976 451672
 sys/doc/cleanps - 775 sys sys 961259933 184
 sys/doc/colophon.ps - 664 sys sys 960837922 214122
-sys/doc/comp.ms - 664 sys sys 954266992 37792
+sys/doc/comp.ms - 664 sys sys 1138396405 37832
 sys/doc/comp.ps - 664 sys sys 960837915 345786
-sys/doc/compiler.ms - 664 sys sys 1067721142 30279
+sys/doc/compiler.ms - 664 sys sys 1138396405 30305
 sys/doc/compiler.ps - 664 sys sys 1091459054 309735
-sys/doc/contents.ms - 664 sys sys 1019916701 4920
+sys/doc/contents.ms - 664 sys sys 1138396405 5409
 sys/doc/contents.ps - 664 sys sys 1019916845 232629
 sys/doc/docfonts - 664 sys sys 1038117516 208
 sys/doc/fonts - 664 sys sys 944959649 137
-sys/doc/fossil.ms - 664 sys sys 1063856349 31400
+sys/doc/fossil.ms - 664 sys sys 1138396406 31439
 sys/doc/fossil.pdf - 664 sys sys 1042123169 63200
 sys/doc/fossil.ps - 664 sys sys 1135487951 313552
 sys/doc/fs - 20000000775 sys sys 945616779 0
 sys/doc/fs/fs.pdf - 664 sys sys 1020384351 47177
 sys/doc/fs/fs.ps - 664 sys sys 960837905 276918
 sys/doc/fs/mkfile - 664 sys sys 961259926 282
-sys/doc/fs/p0 - 664 sys sys 953844580 652
+sys/doc/fs/p0 - 664 sys sys 1138396562 682
 sys/doc/fs/p1 - 664 sys sys 953844581 989
 sys/doc/fs/p2 - 664 sys sys 953844581 3749
 sys/doc/fs/p3 - 664 sys sys 944959592 1475
@@ -5644,7 +5645,7 @@ sys/doc/fs/p7 - 664 sys sys 953844581 958
 sys/doc/fs/p8 - 664 sys sys 953844574 881
 sys/doc/fs/xx - 664 sys sys 944959592 65957
 sys/doc/il - 20000000775 sys sys 945616779 0
-sys/doc/il/il.ms - 664 sys sys 952880783 11367
+sys/doc/il/il.ms - 664 sys sys 1138396552 11390
 sys/doc/il/il.pdf - 664 sys sys 1020384351 44630
 sys/doc/il/il.ps - 664 sys sys 960837905 258028
 sys/doc/il/mkfile - 664 sys sys 961259927 214
@@ -5653,42 +5654,42 @@ sys/doc/il/transition.fig - 664 sys sys 944959591 15431
 sys/doc/il/transition.pic - 664 sys sys 944959591 11912
 sys/doc/il/xx - 664 sys sys 944959591 48924
 sys/doc/index.htm - 664 sys sys 1019916696 6906
-sys/doc/lexnames.ms - 664 sys sys 954383595 34046
+sys/doc/lexnames.ms - 664 sys sys 1138396406 34107
 sys/doc/lexnames.ps - 664 sys sys 960837909 335546
-sys/doc/libmach.ms - 664 sys sys 1021579974 24145
+sys/doc/libmach.ms - 664 sys sys 1138396406 24212
 sys/doc/libmach.ps - 664 sys sys 960837916 291283
 sys/doc/lp.ms - 664 sys sys 954614673 22366
 sys/doc/lp.ps - 664 sys sys 960837917 294399
-sys/doc/mk.ms - 664 sys sys 952880779 34413
+sys/doc/mk.ms - 664 sys sys 1138396445 34456
 sys/doc/mk.ps - 664 sys sys 960837917 329779
-sys/doc/mkfile - 664 sys sys 1091459055 4411
-sys/doc/mkfiles.ms - 664 sys sys 952880779 17888
+sys/doc/mkfile - 664 sys sys 1138396461 2393
+sys/doc/mkfiles.ms - 664 sys sys 1138396445 17910
 sys/doc/mkfiles.ps - 664 sys sys 960837918 269496
-sys/doc/names.ms - 664 sys sys 954269607 22103
+sys/doc/names.ms - 664 sys sys 1138396445 22143
 sys/doc/names.ps - 664 sys sys 960837918 288716
 sys/doc/net - 20000000775 sys sys 954033300 0
 sys/doc/net/mkfile - 664 sys sys 961259927 345
-sys/doc/net/net.ms - 664 sys sys 952880783 41191
+sys/doc/net/net.ms - 664 sys sys 1138396534 41237
 sys/doc/net/net.pdf - 664 sys sys 1020384351 82603
 sys/doc/net/net.ps - 664 sys sys 960837908 350053
 sys/doc/net/tree - 664 sys sys 944959636 866
 sys/doc/net/tree.pout - 664 sys sys 944959636 1755
 sys/doc/network.art - 664 sys sys 944959651 2260
 sys/doc/network.pic - 664 sys sys 944959651 4124
-sys/doc/plumb.ms - 664 sys sys 954383596 53250
+sys/doc/plumb.ms - 664 sys sys 1138396446 53312
 sys/doc/plumb.ps - 664 sys sys 960837910 391830
-sys/doc/port.ms - 664 sys sys 1020111393 16694
+sys/doc/port.ms - 664 sys sys 1138396446 16719
 sys/doc/port.ps - 664 sys sys 1020111394 268901
 sys/doc/preamble - 664 sys sys 961259497 203475
 sys/doc/prfile - 775 sys sys 944959668 3782
-sys/doc/prog4.ms - 664 sys sys 1019932830 16485
+sys/doc/prog4.ms - 664 sys sys 1138396446 16563
 sys/doc/prog4.ps - 664 sys sys 1019932831 271581
 sys/doc/ps - 664 sys sys 944959649 1739
-sys/doc/rc.ms - 664 sys sys 1063856321 34373
+sys/doc/rc.ms - 664 sys sys 1138396446 34404
 sys/doc/rc.ps - 664 sys sys 960837920 337955
-sys/doc/release3.ms - 664 sys sys 961261276 5492
+sys/doc/release3.ms - 664 sys sys 1138396446 5538
 sys/doc/release3.ps - 664 sys sys 961261277 230682
-sys/doc/release4.ms - 664 sys sys 1063856338 5160
+sys/doc/release4.ms - 664 sys sys 1138396446 5207
 sys/doc/release4.ps - 664 sys sys 1091459052 230868
 sys/doc/sam - 20000000775 sys sys 945617037 0
 sys/doc/sam/fig1.bm - 464 sys sys 944959645 42200
@@ -5704,20 +5705,20 @@ sys/doc/sam/fig6.pic - 464 sys sys 944959644 1105
 sys/doc/sam/fig7.pic - 464 sys sys 944959644 258
 sys/doc/sam/mkfile - 664 sys sys 961259927 574
 sys/doc/sam/refs - 464 sys sys 944959644 2652
-sys/doc/sam/sam.ms - 464 sys sys 954266468 94536
+sys/doc/sam/sam.ms - 464 sys sys 1138396552 94640
 sys/doc/sam/sam.pdf - 664 sys sys 1020384352 156123
 sys/doc/sam/sam.ps - 664 sys sys 960837910 707546
 sys/doc/sam/sam.tut - 464 sys sys 944959644 40481
-sys/doc/sleep.ms - 664 sys sys 953237030 15206
+sys/doc/sleep.ms - 664 sys sys 1138396447 15272
 sys/doc/sleep.ps - 664 sys sys 960837920 263882
-sys/doc/spin.ms - 664 sys sys 953344522 67475
+sys/doc/spin.ms - 664 sys sys 1138396447 67493
 sys/doc/spin.ps - 664 sys sys 960837923 443064
 sys/doc/title - 664 sys sys 1018974170 740
 sys/doc/title.ps - 664 sys sys 1018974170 214289
 sys/doc/trademarks.ps - 664 sys sys 960837912 217896
 sys/doc/troff.ms - 664 sys sys 953237047 120683
 sys/doc/troff.ps - 664 sys sys 1091459051 782310
-sys/doc/utf.ms - 664 sys sys 952880781 41659
+sys/doc/utf.ms - 664 sys sys 1138396447 41735
 sys/doc/utf.ps - 664 sys sys 960837922 363085
 sys/doc/venti - 20000000775 sys sys 1019852318 0
 sys/doc/venti/Block.gif - 664 sys sys 1019852315 3292
@@ -7036,6 +7037,7 @@ sys/lib/tmac/tmac.antimes - 664 sys sys 964454718 7809
 sys/lib/tmac/tmac.bits - 664 sys sys 944956202 1089
 sys/lib/tmac/tmac.cs - 664 sys sys 1112039298 21324
 sys/lib/tmac/tmac.e - 664 sys sys 964454711 11992
+sys/lib/tmac/tmac.html - 664 sys sys 1138396384 1950
 sys/lib/tmac/tmac.jsdisp - 664 sys sys 944956203 828
 sys/lib/tmac/tmac.m - 664 sys sys 944956203 87
 sys/lib/tmac/tmac.mcs - 664 sys sys 955115425 43067
@@ -7045,7 +7047,7 @@ sys/lib/tmac/tmac.pictures - 664 sys sys 944956203 4320
 sys/lib/tmac/tmac.psychrefs - 664 sys sys 944956203 608
 sys/lib/tmac/tmac.ptx - 664 sys sys 944956203 330
 sys/lib/tmac/tmac.rscover - 664 sys sys 944956203 2070
-sys/lib/tmac/tmac.s - 664 sys sys 1127393909 23027
+sys/lib/tmac/tmac.s - 664 sys sys 1138396381 23086
 sys/lib/tmac/tmac.scover - 664 sys sys 944956204 4616
 sys/lib/tmac/tmac.sdisp - 664 sys sys 944956204 864
 sys/lib/tmac/tmac.skeep - 664 sys sys 944956204 1346
@@ -7294,6 +7296,7 @@ sys/man/1/gzip - 664 sys sys 1124839836 3226
 sys/man/1/hget - 664 sys sys 1067722859 1483
 sys/man/1/history - 664 sys sys 1109685635 1709
 sys/man/1/hoc - 664 sys sys 1136378274 2357
+sys/man/1/htmlroff - 644 sys sys 1138396051 1831
 sys/man/1/idiff - 664 sys sys 1113743324 914
 sys/man/1/join - 664 sys sys 1113743324 2561
 sys/man/1/jpg - 664 sys sys 1113743325 4842
@@ -7360,7 +7363,7 @@ sys/man/1/syscall - 664 sys sys 1016466457 1439
 sys/man/1/tail - 664 sys sys 1113743327 1413
 sys/man/1/tar - 664 sys sys 1131884436 3439
 sys/man/1/tbl - 664 sys sys 944959674 4308
-sys/man/1/tcs - 664 sys sys 952627441 2575
+sys/man/1/tcs - 664 sys sys 1138383991 2682
 sys/man/1/tee - 664 sys sys 969499886 351
 sys/man/1/tel - 664 sys sys 1045501423 941
 sys/man/1/test - 664 sys sys 1079372544 3535
@@ -7637,11 +7640,13 @@ sys/man/6/authsrv - 664 sys sys 1128483124 13304
 sys/man/6/color - 664 sys sys 988225304 5181
 sys/man/6/face - 664 sys sys 1062505426 2846
 sys/man/6/font - 664 sys sys 1077594184 2528
+sys/man/6/htmlroff - 644 sys sys 1138396325 6608
 sys/man/6/image - 664 sys sys 988225304 6209
 sys/man/6/keyboard - 664 sys sys 1079575918 4418
 sys/man/6/keys.who - 664 sys sys 1110641163 775
 sys/man/6/man - 664 sys sys 944959678 4961
 sys/man/6/map - 664 sys sys 944959678 1892
+sys/man/6/mhtml - 644 sys sys 1138396055 1710
 sys/man/6/mpictures - 664 sys sys 944959678 2899
 sys/man/6/ms - 664 sys sys 958249504 6815
 sys/man/6/namespace - 664 sys sys 1048637182 1576
@@ -12228,6 +12233,35 @@ sys/src/cmd/htmlfmt/html.c - 664 sys sys 1060876449 6032
 sys/src/cmd/htmlfmt/main.c - 664 sys sys 1034015651 1108
 sys/src/cmd/htmlfmt/mkfile - 664 sys sys 1034015650 297
 sys/src/cmd/htmlfmt/util.c - 664 sys sys 1015364025 1765
+sys/src/cmd/htmlroff - 20000000775 sys sys 1138396082 0
+sys/src/cmd/htmlroff/a.h - 664 sys sys 1138396079 3200
+sys/src/cmd/htmlroff/char.c - 664 sys sys 1138396079 2178
+sys/src/cmd/htmlroff/html.c - 664 sys sys 1138396079 3991
+sys/src/cmd/htmlroff/input.c - 664 sys sys 1138396079 3147
+sys/src/cmd/htmlroff/main.c - 664 sys sys 1138396080 1065
+sys/src/cmd/htmlroff/mkfile - 664 sys sys 1138396082 330
+sys/src/cmd/htmlroff/roff.c - 664 sys sys 1138396080 10842
+sys/src/cmd/htmlroff/t1.c - 664 sys sys 1138396080 2816
+sys/src/cmd/htmlroff/t10.c - 664 sys sys 1138396080 1911
+sys/src/cmd/htmlroff/t11.c - 664 sys sys 1138396080 1200
+sys/src/cmd/htmlroff/t12.c - 664 sys sys 1138396080 600
+sys/src/cmd/htmlroff/t13.c - 664 sys sys 1138396080 210
+sys/src/cmd/htmlroff/t14.c - 664 sys sys 1138396080 561
+sys/src/cmd/htmlroff/t15.c - 664 sys sys 1138396080 138
+sys/src/cmd/htmlroff/t16.c - 664 sys sys 1138396080 2270
+sys/src/cmd/htmlroff/t17.c - 664 sys sys 1138396081 1711
+sys/src/cmd/htmlroff/t18.c - 664 sys sys 1138396081 1125
+sys/src/cmd/htmlroff/t19.c - 664 sys sys 1138396081 2353
+sys/src/cmd/htmlroff/t2.c - 664 sys sys 1138396081 4079
+sys/src/cmd/htmlroff/t20.c - 664 sys sys 1138396081 1025
+sys/src/cmd/htmlroff/t3.c - 664 sys sys 1138396081 851
+sys/src/cmd/htmlroff/t4.c - 664 sys sys 1138396081 1974
+sys/src/cmd/htmlroff/t5.c - 664 sys sys 1138396081 1749
+sys/src/cmd/htmlroff/t6.c - 664 sys sys 1138396081 1135
+sys/src/cmd/htmlroff/t7.c - 664 sys sys 1138396082 8626
+sys/src/cmd/htmlroff/t8.c - 664 sys sys 1138396082 6245
+sys/src/cmd/htmlroff/t9.c - 664 sys sys 1138396082 47
+sys/src/cmd/htmlroff/util.c - 664 sys sys 1138396082 1615
 sys/src/cmd/iconv.c - 664 sys sys 1039753035 1801
 sys/src/cmd/idiff.c - 664 sys sys 1014926695 6896
 sys/src/cmd/import.c - 664 sys sys 1133180705 7028
@@ -13299,6 +13333,7 @@ sys/src/cmd/tbl/tt.c - 664 sys sys 944961244 1708
 sys/src/cmd/tbl/tu.c - 664 sys sys 944961244 4817
 sys/src/cmd/tbl/tv.c - 664 sys sys 944961244 3329
 sys/src/cmd/tcs - 20000000775 sys sys 954034511 0
+sys/src/cmd/tcs/8859.h - 644 sys sys 1138382778 16466
 sys/src/cmd/tcs/big5.c - 664 sys sys 944961288 99606
 sys/src/cmd/tcs/big5.h - 664 sys sys 944961287 112
 sys/src/cmd/tcs/conv.h - 664 sys sys 1135487940 941
@@ -13306,7 +13341,7 @@ sys/src/cmd/tcs/conv_big5.c - 664 sys sys 944961288 2821
 sys/src/cmd/tcs/conv_gb.c - 664 sys sys 944961287 2210
 sys/src/cmd/tcs/conv_jis.c - 664 sys sys 944961289 10998
 sys/src/cmd/tcs/conv_ksc.c - 664 sys sys 944961288 2716
-sys/src/cmd/tcs/cyrillic.h - 664 sys sys 944961287 9508
+sys/src/cmd/tcs/cyrillic.h - 664 sys sys 1138382779 7921
 sys/src/cmd/tcs/desc.latin - 664 sys sys 944961287 20189
 sys/src/cmd/tcs/ex2.utf - 664 sys sys 944961288 14431
 sys/src/cmd/tcs/ex3.utf - 664 sys sys 944961288 807
@@ -13330,7 +13365,7 @@ sys/src/cmd/tcs/font/qbits.c - 664 sys sys 944961251 2037
 sys/src/cmd/tcs/gb.c - 664 sys sys 944961288 62707
 sys/src/cmd/tcs/gb.h - 664 sys sys 944961287 183
 sys/src/cmd/tcs/hdr.h - 664 sys sys 944961287 1213
-sys/src/cmd/tcs/html.c - 664 sys sys 1135958471 5247
+sys/src/cmd/tcs/html.c - 664 sys sys 1138381110 5244
 sys/src/cmd/tcs/jis.h - 664 sys sys 944961287 2873
 sys/src/cmd/tcs/ksc.c - 664 sys sys 944961289 72413
 sys/src/cmd/tcs/ksc.h - 664 sys sys 944961287 112
@@ -13338,9 +13373,11 @@ sys/src/cmd/tcs/kuten208.c - 664 sys sys 948046995 59960
 sys/src/cmd/tcs/kuten208.h - 664 sys sys 944961287 94
 sys/src/cmd/tcs/kuten212.c - 664 sys sys 944961289 55407
 sys/src/cmd/tcs/kuten212.h - 664 sys sys 944961287 94
-sys/src/cmd/tcs/mkfile - 664 sys sys 1135487940 542
+sys/src/cmd/tcs/misc.h - 644 sys sys 1138382780 19274
+sys/src/cmd/tcs/mkfile - 664 sys sys 1138382781 591
+sys/src/cmd/tcs/ms.h - 644 sys sys 1138382780 44069
 sys/src/cmd/tcs/plan9.h - 664 sys sys 944961287 751
-sys/src/cmd/tcs/tcs.c - 664 sys sys 1135487940 54089
+sys/src/cmd/tcs/tcs.c - 664 sys sys 1138382781 15489
 sys/src/cmd/tcs/utf.c - 664 sys sys 1125501123 7962
 sys/src/cmd/tee.c - 664 sys sys 954970286 1062
 sys/src/cmd/telco - 20000000775 sys sys 1015701205 0

+ 77 - 0
dist/replica/plan9.log

@@ -27247,3 +27247,80 @@
 1138240891 0 c rc/bin/9fs - 775 sys sys 1138240042 1027
 1138336318 0 c sys/man/2/bio - 664 sys sys 1138335268 6523
 1138336318 1 c sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1138335303 44583
+1138381270 0 c sys/src/cmd/tcs/html.c - 664 sys sys 1138381110 5244
+1138383071 0 c 386/bin/tcs - 775 sys sys 1138382789 309719
+1138383071 1 a sys/src/cmd/tcs/8859.h - 644 sys sys 1138382778 16466
+1138383071 2 c sys/src/cmd/tcs/cyrillic.h - 664 sys sys 1138382779 7921
+1138383071 3 a sys/src/cmd/tcs/misc.h - 644 sys sys 1138382780 19274
+1138383071 4 c sys/src/cmd/tcs/mkfile - 664 sys sys 1138382781 591
+1138383071 5 a sys/src/cmd/tcs/ms.h - 644 sys sys 1138382780 44069
+1138383071 6 c sys/src/cmd/tcs/tcs.c - 664 sys sys 1138382781 15489
+1138384871 0 c sys/man/1/tcs - 664 sys sys 1138383991 2682
+1138386672 0 c rc/bin/9fs - 775 sys sys 1138385380 986
+1138393874 0 c 386/bin/tcs - 775 sys sys 1138393253 309719
+1138397475 0 c sys/doc/8½/8½.ms - 664 sys sys 1138396551 31721
+1138397475 1 c sys/doc/9.ms - 664 sys sys 1138396402 84662
+1138397475 2 c sys/doc/acid.ms - 664 sys sys 1138396403 65160
+1138397475 3 c sys/doc/acidpaper.ms - 664 sys sys 1138396403 44851
+1138397475 4 c sys/doc/acme/acme.ms - 664 sys sys 1138396552 50028
+1138397475 5 c sys/doc/ape.ms - 664 sys sys 1138396403 12637
+1138397475 6 c sys/doc/asm.ms - 664 sys sys 1138396403 31516
+1138397475 7 c sys/doc/auth.ms - 664 sys sys 1138396404 66854
+1138397475 8 c sys/doc/comp.ms - 664 sys sys 1138396405 37832
+1138397475 9 c sys/doc/compiler.ms - 664 sys sys 1138396405 30305
+1138397475 10 c sys/doc/fs/p0 - 664 sys sys 1138396562 682
+1138397475 11 c sys/doc/il/il.ms - 664 sys sys 1138396552 11390
+1138397475 12 c sys/doc/lexnames.ms - 664 sys sys 1138396406 34107
+1138397475 13 c sys/doc/libmach.ms - 664 sys sys 1138396406 24212
+1138397475 14 c sys/doc/mk.ms - 664 sys sys 1138396445 34456
+1138397475 15 c sys/doc/mkfile - 664 sys sys 1138396461 2393
+1138397475 16 c sys/doc/mkfiles.ms - 664 sys sys 1138396445 17910
+1138397475 17 c sys/doc/names.ms - 664 sys sys 1138396445 22143
+1138397475 18 c sys/doc/net/net.ms - 664 sys sys 1138396534 41237
+1138397475 19 c sys/doc/plumb.ms - 664 sys sys 1138396446 53312
+1138397475 20 c sys/doc/port.ms - 664 sys sys 1138396446 16719
+1138397475 21 c sys/doc/prog4.ms - 664 sys sys 1138396446 16563
+1138397475 22 c sys/doc/rc.ms - 664 sys sys 1138396446 34404
+1138397475 23 c sys/doc/release3.ms - 664 sys sys 1138396446 5538
+1138397475 24 c sys/doc/release4.ms - 664 sys sys 1138396446 5207
+1138397475 25 c sys/doc/sam/sam.ms - 464 sys sys 1138396552 94640
+1138397475 26 c sys/doc/sleep.ms - 664 sys sys 1138396447 15272
+1138397475 27 c sys/doc/utf.ms - 664 sys sys 1138396447 41735
+1138397475 28 c sys/doc/contents.ms - 664 sys sys 1138396405 5409
+1138397475 29 c sys/doc/fossil.ms - 664 sys sys 1138396406 31439
+1138397475 30 c sys/doc/spin.ms - 664 sys sys 1138396447 67493
+1138397475 31 a sys/lib/tmac/tmac.html - 664 sys sys 1138396384 1950
+1138397475 32 c sys/lib/tmac/tmac.s - 664 sys sys 1138396381 23086
+1138397475 33 a sys/man/1/htmlroff - 644 sys sys 1138396051 1831
+1138397475 34 a sys/man/6/htmlroff - 644 sys sys 1138396325 6608
+1138397475 35 a sys/man/6/mhtml - 644 sys sys 1138396055 1710
+1138397475 36 a sys/src/cmd/htmlroff - 20000000775 sys sys 1138396082 0
+1138397475 37 a sys/src/cmd/htmlroff/a.h - 664 sys sys 1138396079 3200
+1138397475 38 a sys/src/cmd/htmlroff/char.c - 664 sys sys 1138396079 2178
+1138397475 39 a sys/src/cmd/htmlroff/html.c - 664 sys sys 1138396079 3991
+1138397475 40 a sys/src/cmd/htmlroff/input.c - 664 sys sys 1138396079 3147
+1138397475 41 a sys/src/cmd/htmlroff/main.c - 664 sys sys 1138396080 1065
+1138397475 42 a sys/src/cmd/htmlroff/mkfile - 664 sys sys 1138396082 330
+1138397475 43 a sys/src/cmd/htmlroff/roff.c - 664 sys sys 1138396080 10842
+1138397475 44 a sys/src/cmd/htmlroff/t1.c - 664 sys sys 1138396080 2816
+1138397475 45 a sys/src/cmd/htmlroff/t10.c - 664 sys sys 1138396080 1911
+1138397475 46 a sys/src/cmd/htmlroff/t11.c - 664 sys sys 1138396080 1200
+1138397475 47 a sys/src/cmd/htmlroff/t12.c - 664 sys sys 1138396080 600
+1138397475 48 a sys/src/cmd/htmlroff/t13.c - 664 sys sys 1138396080 210
+1138397475 49 a sys/src/cmd/htmlroff/t14.c - 664 sys sys 1138396080 561
+1138397475 50 a sys/src/cmd/htmlroff/t15.c - 664 sys sys 1138396080 138
+1138397475 51 a sys/src/cmd/htmlroff/t16.c - 664 sys sys 1138396080 2270
+1138397475 52 a sys/src/cmd/htmlroff/t17.c - 664 sys sys 1138396081 1711
+1138397475 53 a sys/src/cmd/htmlroff/t18.c - 664 sys sys 1138396081 1125
+1138397475 54 a sys/src/cmd/htmlroff/t19.c - 664 sys sys 1138396081 2353
+1138397475 55 a sys/src/cmd/htmlroff/t2.c - 664 sys sys 1138396081 4079
+1138397475 56 a sys/src/cmd/htmlroff/t20.c - 664 sys sys 1138396081 1025
+1138397475 57 a sys/src/cmd/htmlroff/t3.c - 664 sys sys 1138396081 851
+1138397475 58 a sys/src/cmd/htmlroff/t4.c - 664 sys sys 1138396081 1974
+1138397475 59 a sys/src/cmd/htmlroff/t5.c - 664 sys sys 1138396081 1749
+1138397475 60 a sys/src/cmd/htmlroff/t6.c - 664 sys sys 1138396081 1135
+1138397475 61 a sys/src/cmd/htmlroff/t7.c - 664 sys sys 1138396082 8626
+1138397475 62 a sys/src/cmd/htmlroff/t8.c - 664 sys sys 1138396082 6245
+1138397475 63 a sys/src/cmd/htmlroff/t9.c - 664 sys sys 1138396082 47
+1138397475 64 a sys/src/cmd/htmlroff/util.c - 664 sys sys 1138396082 1615
+1138408277 0 a 386/bin/htmlroff - 775 sys sys 1138406772 148065

+ 1 - 2
rc/bin/9fs

@@ -21,8 +21,7 @@ case juke
 	srv -q il!jukefs && mount /srv/il!jukefs /n/njuke && bind -c /n/njuke/juke /n/juke
 case sources
 	srv -q tcp!sources.cs.bell-labs.com sources /n/sources &&
-		{ mount /srv/sources /n/sources ||
-		  mount -n /srv/sources /n/sources }
+		mount -n /srv/sources /n/sources
 case sourcesdump
 	9fs sources
 	mount /srv/sources /n/sourcesdump main/archive

+ 5 - 2
sys/doc/8½/8½.ms

@@ -1,3 +1,4 @@
+.HTML "8½, the Plan 9 Window System
 .TL
 8½, the Plan 9 Window System
 .AU
@@ -499,7 +500,8 @@ message:
 2 bytes of boolean function code
 .DE
 .KF
-.BP fig1.ps 4.16 5.6 r 0 0
+.ie h .html - <center><a href="8½.fig1.png"><img src="8½.fig1s.png"></a></center>
+.el .BP fig1.ps 4.16 5.6 r 0 0
 .EP
 .IP
 Figure 1.
@@ -657,7 +659,8 @@ An example
 .PP
 Here is a complete program that runs under 8½.
 It prints the string
-.CW \&"hello\ world"
+.CW \&"hello
+.CW world"
 wherever the left mouse button is depressed, and exits when the
 right mouse button is depressed.
 It also prints the string in the center of its window, and maintains

+ 1 - 0
sys/doc/9.ms

@@ -1,3 +1,4 @@
+.HTML "Plan 9 from Bell Labs"
 .TL
 Plan 9 from Bell Labs
 .AU

+ 4 - 1
sys/doc/acid.ms

@@ -1,3 +1,4 @@
+.HTML "Acid Manual
 .am DS
 .ft I
 ..
@@ -1037,8 +1038,10 @@ description; where a parameter can be of any type it is specified as type
 .I item .
 .de Ip
 .KS
+.in 0
 .LP
-.tl '\f2\\$1\fP\ \ \f(CW\\$2(\f2\\$3\f(CW)\f1''\\$4'
+.ie h \&\f2\\$1\fP\ \ \f(CW\\$2(\f2\\$3\f(CW)\f1\ \ \ \ \ \ \ \ \\$4
+.el .tl '\f2\\$1\fP\ \ \f(CW\\$2(\f2\\$3\f(CW)\f1''\\$4'
 .IP
 ..
 .de Ex

+ 1 - 0
sys/doc/acidpaper.ms

@@ -1,3 +1,4 @@
+.HTML "Acid: A Debugger Built From A Language
 .TL
 Acid: A Debugger Built From A Language
 .AU

+ 17 - 5
sys/doc/acme/acme.ms

@@ -1,3 +1,4 @@
+.HTML "Acme: A User Interface for Programmers
 .de EX
 .nr x \\$1v
 \\!h0c n \\nx 0
@@ -6,7 +7,7 @@
 .KF
 .BP \\$1 \\$2
 .sp .5v
-.EX \\$2v
+.if !h .EX \\$2v
 .ps -1
 .vs -1
 ..
@@ -17,6 +18,17 @@
 \l'1i'
 .KE
 ..
+.if h \{\
+.de FG
+.B1 10 60
+.html - <center><a href="\\$1.png"><img src="\\$1s.png" /></a></center>
+.\" .sp .5v
+..
+.de fg
+.br
+.B2
+..
+.\}
 .TL
 Acme: A User Interface for Programmers
 .AU
@@ -25,8 +37,8 @@ Acme: A User Interface for Programmers
 .SP .22i exactly
 .AB
 .FS
-\l'1i'
-.br
+.if !h \l'1i'
+.if !h .br
 Originally appeared in
 .I
 Proc. of the Winter 1994 USENIX Conf.,
@@ -78,7 +90,7 @@ that do involve the mouse as an integral part of the interaction
 are geared towards general users, not experts, and certainly
 not programmers.
 Software developers, at least on time-sharing systems, have been left behind.
-.FG /usr/rob/doc/acme.fig1 5i
+.FG acme.fig1 5i
 Figure 1.  A small Acme screen\(emnormally it runs on a larger display\(emdemonstrating
 some of the details discussed in the text.
 The right column contains some guide files,
@@ -162,7 +174,7 @@ and finally presents some unusual aspects of its implementation.
 .SH
 User interface
 .PP
-.FG /usr/rob/doc/acme.fig2 3i
+.FG acme.fig2 3i
 Figure 2.  An Acme window showing a section of code.
 The upper line of text is the tag containing the file name,
 relevant commands, and a scratch area (right of the vertical bar);

+ 1 - 0
sys/doc/ape.ms

@@ -1,3 +1,4 @@
+.HTML "APE — The ANSI/POSIX Environment
 .de XX
 .IP \ \ \ \-
 ..

+ 101 - 0
sys/doc/asm.ms

@@ -1,3 +1,4 @@
+.HTML "A Manual for the Plan 9 assembler
 .ft CW
 .ta 8n +8n +8n +8n +8n +8n +8n
 .ft
@@ -291,6 +292,9 @@ The 386 has all three:
 .CW WORD ,
 and
 .CW BYTE .
+The AMD64 adds
+.CW QUAD
+to that for 64-bit values.
 The 960 has only one,
 .CW LONG .)
 .PP
@@ -894,6 +898,103 @@ Segment override prefixes in
 .CW MOD/RM
 fields are not supported.
 .SH
+AMD64
+.PP
+The assembler assumes 64-bit mode unless a
+.CW MODE
+pseudo-operation is given:
+.P1
+	MODE $32
+.P2
+to change to 32-bit mode.
+The effect is mainly to diagnose instructions that are illegal in
+the given mode, but the loader will also assume 32-bit operands and addresses,
+and 32-bit PC values for call and return.
+The assembler's conventions are similar to those for the 386, above.
+The architecture provides extra fixed-point registers
+.CW R8
+to
+.CW R15 .
+All registers are 64 bit, but instructions access low-order 8, 16 and 32 bits
+as described in the processor handbook.
+For example,
+.CW MOVL
+to
+.CW AX
+puts a value in the low-order 32 bits and clears the top 32 bits to zero.
+Literal operands are limited to signed 32 bit values, which are sign-extended
+to 64 bits in 64 bit operations; the exception is
+.CW MOVQ ,
+which allows 64-bit literals.
+The external registers in Plan 9's C are allocated from
+.CW R15
+down.
+There are many new instructions, including the MMX and XMM media instructions,
+and conditional move instructions.
+MMX registers are
+.CW M0
+to
+.CW M7 ,
+and
+XMM registers are
+.CW X0
+to
+.CW X15 .
+As with the 386 instruction names,
+all new 64-bit integer instructions, and the MMX and XMM instructions
+uniformly use
+.CW L
+for `long word' (32 bits) and
+.CW Q
+for `quad word' (64 bits).
+Some instructions use
+.CW O
+(`octword') for 128-bit values, where the processor handbook
+variously uses
+.CW O
+or
+.CW DQ .
+The assembler also consistently uses
+.CW PL
+for `packed long' in
+XMM instructions, instead of
+.CW Q ,
+.CW DQ
+or
+.CW PI .
+Either
+.CW MOVL
+or
+.CW MOVQ
+can be used to move values to and from control registers, even when
+the registers might be 64 bits.
+The assembler often accepts the handbook's name to ease conversion
+of existing code (but remember that the operand order is uniformly
+source then destination).
+C's
+.CW "long long"
+type is 64 bits, but passed and returned by value, not by reference.
+More notably, C pointer values are 64 bits, and thus
+.CW "long long"
+and
+.CW "unsigned long long"
+are the only integer types wide enough to hold a pointer value.
+The C compiler and library use the XMM floating-point instructions, not
+the old 387 ones, although the latter are implemented by assembler and loader.
+Unlike the 386, the first integer or pointer argument is passed in a register, which is
+.CW BP
+for an integer or pointer (it can be referred to in assembly code by the pseudonym
+.CW RARG ).
+.CW AX
+holds the return value from subroutines as before.
+Floating-point results are returned in
+.CW X0 ,
+although currently the first floating-point parameter is not passed in a register.
+All parameters less than 8 bytes in length have 8 byte slots reserved on the stack
+to preserve alignment and simplify variable-length argument list access,
+including the first parameter when passed in a register,
+even though bytes 4 to 7 are not initialized.
+.SH
 Alpha
 .PP
 On the Alpha, all registers are 64 bits.  The architecture handles 32-bit values

+ 4 - 1
sys/doc/auth.ms

@@ -1,3 +1,4 @@
+.HTML "Security in Plan 9
 .de SS
 .NH 2
 ..
@@ -46,7 +47,7 @@ applications.
 has an unusual architecture: it is implemented
 as a Plan 9 file server.
 .FS
-To appear, in a slightly different form, in
+Appeared, in a slightly different form, in
 .I
 Proc. of the 2002 Usenix Security Symposium,
 .R
@@ -155,6 +156,7 @@ Transport Layer Security (TLS)
 [RFC2246];
 and began using encryption for all communications within the system.
 The overall architecture is illustrated in Figure 1a.
+.if h .B1 10 60
 .KF
 .EQ
 gsize 9
@@ -221,6 +223,7 @@ is a shared resource for storing private information such as keys;
 consults it for the user during bootstrap.
 .sp
 .KE
+.if h .B2
 .EQ
 gsize 11
 .EN

+ 1 - 0
sys/doc/comp.ms

@@ -1,3 +1,4 @@
+.HTML "How to Use the Plan 9 C Compiler
 .TL
 How to Use the Plan 9 C Compiler
 .AU

+ 1 - 0
sys/doc/compiler.ms

@@ -1,3 +1,4 @@
+.HTML "Plan 9 C Compilers
 .TL
 Plan 9 C Compilers
 .AU

+ 46 - 31
sys/doc/contents.ms

@@ -1,3 +1,4 @@
+.HTML "Plan 9 — The Documents (Volume 2)
 .FP lucidasans
 .na
 .ds CH
@@ -12,8 +13,18 @@
 ..
 .de Ti
 .ft R
+.ie h \{\
+\\$3 
+(\c
+.if !'\\$2'troff' \! \<a href="\\$2.html"\>html\</a\> |
+\! \<a href="\\$2.ps"\>ps\</a\>
+|
+\! \<a href="\\$2.pdf"\>pdf\</a\>)
+.\}
+.el \{\
 .ta \\n(LLuR
-\\$2 \a\|\|\\$1
+\\$3 \a\|\|\\$1
+.\}
 .br
 ..
 .de Au
@@ -42,122 +53,126 @@
 .LP
 .ps 12
 .ce
-.B "Table of Contents
+.ie h .B "Plan 9 \(em The Documents (Volume 2)
+.el .B "Table of Contents
 .ps
 .sp .5i
 .He "Introduction
-.Ti 1 "Plan 9 From Bell Labs
+.Ti 1 9 "Plan 9 From Bell Labs
 .Au "Rob Pike, Dave Presotto, Sean Dorward, Bob Flandrena, Ken Thompson, Howard Trickey, and Phil \%Winterbottom
 .De "An overview of the system; read at least this paper before you install.
 .Co seems ok; a little dated; unchanged except to mention appearance in Computing Systems
-.Ti 23 "The Use of Name Spaces in Plan 9
+.Ti 23 names "The Use of Name Spaces in Plan 9
 .Au "Rob Pike, Dave Presotto, Ken Thompson, Howard Trickey, and Phil \%Winterbottom
 .Co updated only to mention appearance in SIGOPS
 .De "What's in a name?
-.Ti 29 "The Organization of Networks in Plan 9
+.Ti 29 net "The Organization of Networks in Plan 9
 .Au "Dave Presotto and Phil Winterbottom
 .De "Connecting the pieces.  The details in the paper are outdated but the ideas still apply.
-.Ti 43 "Security in Plan 9
+.Ti 43 auth "Security in Plan 9
 .Au "Russ Cox, Eric Grosse, Rob Pike, Dave Presotto, and Sean Quinlan
 .De "An overview of the security architecture.
 .He "Programming
-.Ti 63 "How to Use the Plan 9 C Compiler
+.Ti 63 comp "How to Use the Plan 9 C Compiler
 .Au "Rob Pike
 .Co updated
 .De "The starting point for C programming under Plan 9.
-.Ti 77 "Changes to the Programming Environment in the Fourth Release of Plan 9
+.Ti 77 prog4 "Changes to the Programming Environment in the Fourth Release of Plan 9
 .Au "Rob Pike
 .De "An overview of the changes to the C library since the Third Release.
-.Ti 83 "APE \(em The ANSI/POSIX Environment
+.Ti 83 ape "APE \(em The ANSI/POSIX Environment
 .Au "Howard Trickey
 .Co updated
 .De "Moving C code between UNIX and Plan 9.
-.Ti 87 "Acid: A Debugger Built From A Language
+.Ti 87 acidpaper "Acid: A Debugger Built From A Language
 .Au "Phil Winterbottom
 .Co fine
 .De "An overview paper about the Acid debugger.
-.Ti 101 "Acid Manual
+.Ti 101 acid "Acid Manual
 .Au "Phil Winterbottom
 .Co updated
 .De "The reference manual for the language and its libraries.
-.Ti 127 "Maintaining Files on Plan 9 with Mk
+.Ti 127 mk "Maintaining Files on Plan 9 with Mk
 .Au "Andrew G. Hume and Bob Flandrena
 .Co updated
 .De "An introduction to Plan 9's replacement for \f(CWmake\fP.
-.Ti 141 "Plan 9 Mkfiles
+.Ti 141 mkfiles "Plan 9 Mkfiles
 .Au "Bob Flandrena
 .Co updated
 .De "The conventions for using \f(CWmk\fP in Plan 9.
-.Ti 149 "A Manual for the Plan 9 assembler
+.Ti 149 asm "A Manual for the Plan 9 assembler
 .Au "Rob Pike
 .Co updated
 .De "Things you'd rather not know.
 .bp
 .He "User Interfaces
-.Ti 159 "8½, the Plan 9 Window System
+.Ti 159 "8½, the Plan 9 Window System
 .Au "Rob Pike
 .Co fine - introductory footnote tweaked
 .De "An introduction to the (previous) window system and its unusual implementation.
-.Ti 169 "Rc \(em The Plan 9 Shell
+.Ti 169 rc "Rc \(em The Plan 9 Shell
 .Au "Tom Duff
 .Co updated
 .De "An introduction to the new shell, complete with examples.
-.Ti 185 "The Text Editor \&\f(CWsam\fP
+.Ti 185 sam "The Text Editor \&\f(CWsam\fP
 .Au "Rob Pike
 .Co fine
 .De "\f(CWSam\fP is the standard editor on Plan 9.
-.Ti 215 "Acme: A User Interface for Programmers
+.Ti 215 acme "Acme: A User Interface for Programmers
 .Au "Rob Pike
 .Co fine
 .De "A system with a more radical approach to programming and editing.
-.Ti 231 "Plumbing and Other Utilities
+.Ti 231 plumb "Plumbing and Other Utilities
 .Au "Rob Pike
 .Co new
 .De "Inter-process communication that enlivens the interactive user interface.
 .He "Implementation
-.Ti 247 "Hello World, or Καλημέρα κόσμε, or \f(Jpこんにちは 世界\fP
+.Ti 247 utf "Hello World, or Καλημέρα κόσμε, or \f(Jpこんにちは 世界\fP
 .Au "Rob Pike and Ken Thompson
 .Co fine
 .De "The details about Plan 9's character set: the Unicode Standard plus an ASCII-compatible encoding.
-.Ti 259 "Plan 9 C Compilers
+.Ti 259 compiler "Plan 9 C Compilers
 .Au "Ken Thompson
 .Co updated
 .De "The design and some internals of the compiler suite.
-.Ti 271 "Adding Application Support for a New Architecture in Plan 9
+.Ti 271 libmach "Adding Application Support for a New Architecture in Plan 9
 .Au "Bob Flandrena
 .Co updated
 .De "The procedures necessary to add a new instruction set to Plan 9's programming environment.
-.Ti 279 "The Plan 9 File Server
+.Ti 279 fs "The Plan 9 File Server
 .Au "Ken Thompson
 .Co updated
 .De "The design of the central file server and its novel backup system.
-.Ti 287 "Venti: A new approach to archival storage
+.Ti 287 venti "Venti: A new approach to archival storage
 .Au "Sean Quinlan and Sean Dorward
 .De "Archival block-level storage using secure hashes as block identifiers.
-.Ti 301 "The IL protocol
+.Ti 301 il "The IL protocol
 .Au "Dave Presotto and Phil Winterbottom
 .De "A description of the Internet protocol Plan 9 uses for internal communication.
-.Ti 307 "Lexical File Names in Plan 9, or, Getting Dot-Dot Right
+.Ti 307 lexnames "Lexical File Names in Plan 9, or, Getting Dot-Dot Right
 .Au "Rob Pike
 .Co new
 .De "A vexing old problem solved: how to make \f(CWpwd\fP get the right answer in the face of multiply-bound directories.
-.Ti 319 "Process Sleep and Wakeup on a Shared-memory Multiprocessor
+.Ti 319 sleep "Process Sleep and Wakeup on a Shared-memory Multiprocessor
 .Au "Rob Pike, Dave Presotto, Ken Thompson, and Gerard Holzmann
 .Co fine - updated with citation footnote
 .De "A detailed study of a central issue in the Plan 9 kernel.
 .He "Miscellany
-.Ti 325 "A Guide to the Lp Printer Spooler
+.Ti 325 lp "A Guide to the Lp Printer Spooler
 .Au "Paul Glick
 .De "Adminstering the suite of tools to drive PostScript printers.
-.Ti 333 "Troff User's Manual
+.Ti 333 troff "Troff User's Manual
 .Au "Joseph F. Ossanna and Brian W. Kernighan
 .Co updated
 .De "The old warhorse, updated for Unicode characters.
 .bp
-.Ti 373 "Using SPIN
+.Ti 373 spin "Using SPIN
 .Au "Gerard Holzmann
 .Co updated
 .De "An introduction to a tool for analyzing parallel and distributed programs.
 .He "Installation
-.Ti 400 "The Various Ports
+.Ti 400 port "The Various Ports
 .De "The hardware requirements for the Plan 9 compilers and kernels.
+.if h \{\
+.sp 1
+\! \<center\>\<a href="/plan9/"\>Plan 9 Home Page\</a\>\</center\>

+ 1 - 0
sys/doc/fossil.ms

@@ -1,3 +1,4 @@
+.HTML "Fossil, an Archival File Server
 ... .FP times
 ... .fp 1 R R.nomath
 ... .fp 5 CW LucidaSansCW83

+ 1 - 0
sys/doc/fs/p0

@@ -1,3 +1,4 @@
+.HTML "The Plan 9 File Server
 .FP lucidasans
 .TL
 The Plan 9 File Server

+ 1 - 0
sys/doc/il/il.ms

@@ -1,3 +1,4 @@
+.HTML "The IL Protocol
 .TL
 The IL protocol
 .AU

+ 1 - 0
sys/doc/lexnames.ms

@@ -1,3 +1,4 @@
+.HTML "Lexical File Names in Plan 9 or Getting Dot-Dot Right
 .hw re-create
 .hw re-created
 .TL

+ 1 - 0
sys/doc/libmach.ms

@@ -1,3 +1,4 @@
+.HTML "Adding Application Support for a New Architecture in Plan 9
 .TL
 Adding Application Support for a New Architecture in Plan 9
 .AU

+ 1 - 0
sys/doc/mk.ms

@@ -1,3 +1,4 @@
+.HTML "Maintaining Files on Plan 9 with Mk
 .TL
 Maintaining Files on Plan 9 with Mk
 .AU

+ 92 - 204
sys/doc/mkfile

@@ -1,127 +1,67 @@
+# Changes made in this directory are invisible to the
+# external web server.  To publish changed documents
+# to the external web server, mk install or name.install
+# To publish changed ps/pdf files, see the install rule.
+
 < /sys/doc/fonts
 NPROC = 1
-FILES = \
-	title.ps \
-	trademarks.ps \
-	contents.ps \
-	9.ps \
-	acid.ps \
-	acidpaper.ps \
-	ape.ps \
-	asm.ps \
-	auth.ps \
-	comp.ps \
-	compiler.ps \
-	lexnames.ps \
-	libmach.ps \
-	lp.ps \
-	mk.ps \
-	mkfiles.ps \
-	names.ps \
-	plumb.ps \
-	port.ps \
-	rc.ps \
-	sleep.ps \
-	spin.ps \
-	troff.ps \
-	utf.ps \
-	colophon.ps \
-	release4.ps \
-	prog4.ps\
-
-DIRS = \
-	8½ \
-	acme \
-	fs \
-	venti \
-	il \
-	net \
-	sam \
-
-all:V: dirs
-
-print:V: \
-	title.ps \
-	trademarks.ps \
-	contents.ps\
-	9.ps \
-	names.ps \
-	net/net.ps \
-	auth.ps \
-	comp.ps \
-	prog4.ps \
-	ape.ps \
-	acidpaper.ps \
-	acid.ps \
-	mk.ps \
-	mkfiles.ps \
-	asm.ps \
-	8½/8½.ps \
-	rc.ps \
-	sam/sam.ps \
-	acme/acme.ps \
-	plumb.ps \
-	utf.ps \
-	compiler.ps \
-	libmach.ps \
-	fs/fs.ps \
-	venti/venti.ps \
-	il/il.ps \
-	sleep.ps \
-	lexnames.ps \
-	lp.ps \
-	troff.ps \
-	spin.ps \
-	port.ps \
-	colophon.ps
-	lp -dfn -H -i0 $prereq
 
-html:V: \
-	9.html \
-	names.html \
-	net/net.html \
-	auth.html \
-	comp.html \
-	prog4.html \
-	ape.html \
-	acidpaper.html \
-	acid.html \
-	mk.html \
-	mkfiles.html \
-	asm.html \
-	8½/8½.html \
-	rc.html \
-	sam/sam.html \
-	acme/acme.html \
-	plumb.html \
-	utf.html \
-	compiler.html \
-	libmach.html \
-	fs/fs.html \
-	il/il.html \
-	sleep.html \
-	lexnames.html \
-	lp.html \
-	troff.html \
-	spin.html \
-	port.html \
-	release4.html
-	cp index.htm index.html
-
-dirs:V:	$FILES $DIRS
+ALL=\
+	title\
+	trademarks\
+	contents\
+	9\
+	names\
+	net/net\
+	auth\
+	comp\
+	prog4\
+	ape\
+	acidpaper\
+	acid\
+	mk\
+	mkfiles\
+	asm\
+	8½/8½\
+	rc\
+	sam/sam\
+	acme/acme\
+	plumb\
+	utf\
+	compiler\
+	libmach\
+	fs/fs\
+	venti/venti\
+	il/il\
+	lexnames\
+	sleep\
+	lp\
+	troff\
+	spin\
+	port\
+	colophon\
+
+ALLPS=${ALL:%=%.ps}
+HTML=${ALL:%=%.html} release3.html release4.html
+FILES=`{mkfilelist $ALL}
+DIRS=`{mkdirlist $ALL}
+NAMES=$FILES $DIRS
+
+all:V: ${FILES:%=%.ps} dirs
+
+dirs:V:
 	for(i in $DIRS) @{
 		cd $i
 		mk
 	}
 
+print:V: $ALLPS
+	lp -dfn -H -i0 $prereq
+
 title.ps:D:	title
 	troff $prereq | lp -dstdout > $target
 	cleanps $target
 
-contents.ps:D:	contents.ms
-	{ echo $FONTS; cat $prereq } | troff -ms -mnihongo | lp -dstdout > $target
-	cleanps $target
-
 trademarks.ps:D:	/sys/lib/man/trademarks
 	troff $prereq | lp -dstdout > $target
 	cleanps $target
@@ -130,109 +70,38 @@ colophon.ps:D:	/sys/lib/man/colophon
 	troff $prereq | lp -dstdout > $target
 	cleanps $target
 
-%.page:D:	%.ps
-	page -w $stem.ps
-
+# troff gets some scary-looking errors but they're okay
 %.ps:D:	%.ms
-	{ echo $FONTS; cat $stem.ms } | tbl | troff -ms | lp -dstdout > $target
+	mac=(-ms)
+	if(~ $stem comp utf 9 contents) mac=(-ms -mnihongo)
+	{ echo $FONTS; cat $stem.ms } | pic | tbl | eqn | 
+		troff $mac | lp -dstdout > $target
 	cleanps $target
 
 %.trout:D:	%.ms
-	{ echo $FONTS; cat $stem.ms } | tbl | troff -ms > $stem.trout
+	mac=(-ms)
+	if(~ $stem comp utf 9 contents) mac=($mac -mnihongo)
+	{ echo $FONTS; cat $stem.ms } | pic | tbl | eqn | 
+		troff $mac > $target
 
-troff.trout:D:	troff.ms
-	{ echo $FONTS; cat $prereq } | tbl | eqn | troff -ms > $target
+html:V: $HTML
 
-troff.ps:D:	troff.ms
-	echo this gets some scary-looking errors, but they''''re fine
-	{ echo $FONTS; cat $prereq } | tbl | eqn | troff -ms | lp -dstdout > $target
-	cleanps $target
+9.trout 9.ps 9.html: network.pic
 
-fossil.ps:D: fossil.ms
-	{ echo $FONTS; cat $prereq } | pic | troff -ms | lp -dstdout >$target
-	cleanps $target
+%.html: /$objtype/bin/htmlroff /sys/lib/tmac/tmac.s
 
-auth.ps:D:	auth.ms
-	{ echo $FONTS; cat $prereq } | pic | tbl | eqn  | troff -ms | lp -dstdout > $target
-	cleanps $target
+index.html: contents.html
+	cp contents.html index.html
 
-plumb.ps:D:	plumb.ms
-	{ echo $FONTS; cat $prereq } | pic | troff -ms | lp -dstdout > $target
-	cleanps $target
-
-comp.ps:D:	comp.ms
-	{ echo $FONTS; cat $prereq } | tbl | troff -ms -mnihongo | lp -dstdout > $target
-	cleanps $target
-
-utf.ps:D:	utf.ms
-	{ echo $FONTS; cat $prereq } | tbl | troff -ms -mnihongo | lp -dstdout > $target
-	cleanps $target
-
-9.ps:D:	9.ms network.pic
-	{ echo $FONTS; cat 9.ms } | tbl | pic | troff -ms -mnihongo | lp -dstdout > $target
-	cleanps $target
-
-9.trout:D:	9.ms network.pic
-	{ echo $FONTS; cat 9.ms } | tbl | pic | troff -ms -mnihongo > $target
-
-spin.ps:D:	spin.ms
-	{ echo $FONTS; cat $prereq } | eqn | tbl | troff -ms | lp -dstdout > $target
-	cleanps $target
+&.html:D:	&.ms
+	pic $stem.ms | tbl | eqn | htmlroff -ms -mhtml >$target
 
-%.html:D:	%.ms
-	{ echo $FONTS; cat $stem.ms } | tbl | ms2html > $target
+^(8½|acme|fs|il|net|sam|venti)/([^/]*\.(pdf|ps|html))'$':R:
+	cd $stem1
+	mk $stem2
 
-troff.html:D:	troff.ms
-	{ echo $FONTS; cat $prereq } | tbl | eqn | ms2html > $target
-
-plumb.html:D:	plumb.ms
-	{ echo $FONTS; cat $prereq } | pic | ms2html > $target
-
-auth.html:D:	auth.ms
-	{ echo $FONTS; cat $prereq } | pic |eqn | tbl | ms2html > $target
-
-comp.html:D:	comp.ms
-	{ echo $FONTS; cat $prereq } | tbl | ms2html > $target
-
-utf.html:D:	utf.ms
-	{ echo $FONTS; cat $prereq } | tbl | ms2html > $target
-
-9.html:D:	9.ms network.pic
-	{ echo $FONTS; cat 9.ms } | tbl | pic | ms2html > $target
-
-spin.html:D:	spin.ms
-	{ echo $FONTS; cat $prereq } | eqn | tbl | ms2html > $target
-
-gfx.html:D:	gfx.ms
-	{ echo $FONTS; cat $prereq } | tbl | pic | ms2html > $target
-
-fs/fs.html:
-	cd fs
-	mk fs.html
-
-net/net.html:
-	cd net
-	mk net.html
-
-sam/sam.html:
-	cd sam
-	mk sam.html
-
-acme/acme.html:
-	cd acme
-	mk acme.html
-
-venti/venti.html:
-	cd venti
-	mk venti.html
-
-il/il.html:
-	cd il
-	mk il.html
-
-release4.html:	release4.ms
-	# remove all those extra blank lines
-	{ echo $FONTS; cat release4.ms } | tbl | ms2html | uniq > $target
+^(8½|acme|fs|il|net|sam|venti)\.html'$':R: \1/\1.html
+	cp $stem1/$stem1.html .
 
 %.pdf: %.ps
 	{ cat docfonts $stem.ps } >_$stem.ps
@@ -242,3 +111,22 @@ release4.html:	release4.ms
 %.all:V:
 	mk $stem.ps $stem.pdf $stem.html
 
+%.install:V: %.html
+	9fs other
+	files=`{ls $stem.html $stem^*.png $stem/*.png $stem/*.html >[2]/dev/null}
+	whatis stem
+	whatis files
+	cp $files /n/other/crp/sources.copy/sys/doc
+
+%.page:V:	%.ps
+	page -w $stem.ps
+
+install:V: ${NAMES:%=%.install} release4.install release3.install
+
+# ignore these
+IGNHTML=title trademarks colophon troff
+IGN=${IGNHTML:%=%.html} ${IGNHTML:%=%.install}
+
+$IGN:QV:
+	# nothing
+

+ 1 - 0
sys/doc/mkfiles.ms

@@ -1,3 +1,4 @@
+.HTML "Plan 9 Mkfiles
 .TL
 Plan 9 Mkfiles
 .AU

+ 1 - 0
sys/doc/names.ms

@@ -1,3 +1,4 @@
+.HTML "The Use of Name Spaces in Plan 9
 .TL
 The Use of Name Spaces in Plan 9
 .AU

+ 1 - 0
sys/doc/net/net.ms

@@ -1,3 +1,4 @@
+.HTML "The Organization of Networks in Plan 9
 .TL
 The Organization of Networks in Plan 9
 .AU

+ 3 - 0
sys/doc/plumb.ms

@@ -1,3 +1,4 @@
+.HTML "Plumbing and Other Utilities
 .TL
 Plumbing and Other Utilities
 .AU
@@ -91,6 +92,7 @@ For example,
 is by convention the file from which a text editor reads messages requesting it to
 open and display a file for editing.
 (See Figure 1.)
+.if h .B1 10 60
 .KF
 .PS
 down
@@ -135,6 +137,7 @@ Although the figure doesn't illustrate it, some programs may both send and recei
 and some ports are read by multiple applications.
 .sp
 .KE
+.if h .B2
 .LP
 The plumber takes messages from the
 .CW send

+ 1 - 0
sys/doc/port.ms

@@ -1,3 +1,4 @@
+.HTML "The Various Ports
 .TL
 The Various Ports
 .PP

+ 1 - 0
sys/doc/prog4.ms

@@ -1,3 +1,4 @@
+.HTML "Changes to the Programming Environment in the Fourth Release of Plan 9
 .FP lucidasans
 .TL
 Changes to the Programming Environment

+ 1 - 0
sys/doc/rc.ms

@@ -1,3 +1,4 @@
+.HTML "Rc — The Plan 9 Shell
 .	\" /*% refer -k -e -n -l3,2 -s < % | tbl | troff -ms | lp -dfn
 .Tm shell programming language	g
 .de TP	\" An indented paragraph describing some command, tagged with the command name

+ 1 - 0
sys/doc/release3.ms

@@ -1,3 +1,4 @@
+.HTML "Plan 9 — Third Edition Release Notes
 .TL
 Plan 9 From Bell Labs
 .br

+ 1 - 0
sys/doc/release4.ms

@@ -1,3 +1,4 @@
+.HTML "Plan 9 — Fourth Edition Release Notes
 .TL
 Plan 9 From Bell Labs
 .br

+ 9 - 4
sys/doc/sam/sam.ms

@@ -1,3 +1,4 @@
+.HTML "The Text Editor sam
 .Vx 17 11 November 87 1 32 "ROB PIKE" "THE TEXT EDITOR SAM"
 .ds DY "31 May 1987
 .ds DR "Revised 1 July 1987
@@ -19,6 +20,10 @@
 .vs
 .sp
 ..
+.de XP
+.ie h .html - <center><img src="sam.\\$1.png" /></center>
+.el .BP \\$1.ps \\$2
+..
 .TL
 The Text Editor \&\f(CWsam\fP
 .AU
@@ -255,7 +260,7 @@ the command is assumed to apply to the current text.
 For the moment, ignore the presence of multiple files and consider
 editing a single file.
 .KF L
-.BP fig1.ps 3.5i
+.XP fig1 3.5i
 .Cs
 Figure 1. A typical
 .CW sam
@@ -1272,7 +1277,7 @@ will highlight it on the screen \(em in fact,
 dot is always highlighted (see Figure 2).
 .WS 1
 .KF
-.BP fig3.ps 2.04i
+.XP fig3 2.04i
 .Cs
 Figure 2. A
 .CW sam
@@ -1357,7 +1362,7 @@ Selecting it makes the
 window the current window,
 causing subsequent typing to be interpreted as commands.
 .KF
-.BP fig2.ps 2.74i
+.XP fig2 2.74i
 .Cs
 Figure 3. The menu on button 3.
 The black rectangle on the left is a scroll bar; the menu is limited to
@@ -1449,7 +1454,7 @@ to search
 forward for the next occurrence of a match for the expression.
 .WS 1
 .KF
-.BP fig4.ps 1.20i
+.XP fig4 1.20i
 .Cs
 Figure 4. The menu on button 2.
 The bottom entry tracks the most recently used regular expression, which may

+ 1 - 0
sys/doc/sleep.ms

@@ -1,3 +1,4 @@
+.HTML "Process Sleep and Wakeup on a Shared-memory Multiprocessor
 .TL
 Process Sleep and Wakeup on a Shared-memory Multiprocessor
 .AU

+ 1 - 0
sys/doc/spin.ms

@@ -1,3 +1,4 @@
+.HTML "Using SPIN
 .\" runoff as:
 .\" eqn file | tbl | troff -ms
 .\"

+ 1 - 0
sys/doc/utf.ms

@@ -1,3 +1,4 @@
+.HTML "Hello World or Καλημέρα κόσμε or こんにちは 世界
 .TL
 Hello World
 .br

+ 94 - 0
sys/lib/tmac/tmac.html

@@ -0,0 +1,94 @@
+.de HTML
+\! \<?xml version="1.0" encoding="utf-8"?\>
+\! \<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+\!   "http://www.w3.org/TR/html4/loose.dtd"\>
+.html html <html>
+.html head <head>
+.if !'\\$1'' .html title <title>\\$1</title>
+.HEAD
+.html head
+.html body <body>
+..
+.de FSFIRST
+.de NOTES xx
+._NOTES
+.rm _NOTES
+xx
+.em NOTES
+.da _NOTES
+.sp
+.B "Notes
+.sp
+.da
+..
+.de FS
+.FSFIRST
+.rm FSFIRST
+.da _NOTES
+..
+.de FE
+.sp
+.da
+..
+.nr png -1 1
+.de TS
+.ds pngbase "\\*[basename]
+.if '\\*[pngbase]'' .ds pngbase \\n(.B
+.ds pngfile \\*[pngbase]\\n+[png].png
+.html - <center><img src="\\*[pngfile]"></center>
+.\" The .inputpipe must be the last line of the macro!
+.inputpipe .TE troff2png >\\*[pngfile]
+..
+.de TE
+..
+.de PS
+.ds pngbase "\\*[basename]
+.if '\\*[pngbase]'' .ds pngbase \\n(.B
+.ds pngfile \\*[pngbase]\\n+[png].png
+.html - <center><img src="\\*[pngfile]"></center>
+.inputpipe .PE troff2png >\\*[pngfile]
+..
+.de PE
+..
+.de B1
+.margin 0
+.nr TW 10
+.nr TW1 80
+.if !'\\$1'' .nr TW \\$1
+.if !'\\$2'' .nr TW1 \\$2
+.html box \
+<center>\
+<table width=\\n[TW1]% cellspacing=0 cellpadding=0 border=0>\
+<tr height=1>\
+	<td width=1 bgcolor=#000000 />\
+	<td width=\\n(TW bgcolor=#000000 />\
+	<td bgcolor=#000000 />\
+	<td width=\\n(TW bgcolor=#000000 />\
+	<td width=1 bgcolor=#000000 />\
+</tr>\
+<tr height=\\n(TW>\
+	<td width=1 bgcolor=#000000 />\
+	<td width=\\n(TW />\
+	<td />\
+	<td width=\\n(TW />\
+	<td width=1 bgcolor=#000000 />\
+</tr>
+.html box0 <tr>
+.html box1 <td width=1 bgcolor=#000000 /><td width=\\n(TW /><td>
+..
+.de B2
+.html box1 <td width=\\n(TW /><td width=1 bgcolor=#000000 />
+.html box0 <tr height=\\n(TW><td width=1 bgcolor=#000000 />\
+	<td width=\\n(TW /><td /><td width=\\n(TW />\
+	<td width=1 bgcolor=#000000 />\
+</tr>\
+<tr height=1>\
+	<td width=1 bgcolor=#000000 />\
+	<td width=\\n(TW bgcolor=#000000 />\
+	<td bgcolor=#000000 />\
+	<td width=\\n(TW bgcolor=#000000 />\
+	<td width=1 bgcolor=#000000 />\
+</tr>
+.html box
+.margin 1
+..

+ 7 - 2
sys/lib/tmac/tmac.s

@@ -308,9 +308,11 @@
 .di WT
 .na
 .fi
+.ie h .ll \\n(LLu
+.el \{\
 .ll 5.0i
 .if n .if \\n(TN .ll 29
-.if t .if \\n(TN .ll 3.5i
+.if t .if \\n(TN .ll 3.5i \}
 .ft 3
 .ps \\n(PS
 .if !\\n(TN \{\
@@ -318,6 +320,7 @@
 .	vs \\n(.s+2
 .	rm CS\}
 .hy 0
+.if h .ce 999
 ..
 .de TX
 .rs
@@ -358,6 +361,7 @@
 .		ft 3
 .		ll 16\}\}
 .ps \\n(PS
+.if h .ce 999
 ..
 .de AX
 .ft 1
@@ -1259,7 +1263,8 @@ ABSTRACT
 .ta \\n(JQu \\n(TYuR
 .if \\n(.$ \{\
 .ti \\n(I\\n(IRu
-\&\\$1\t\c\}
+\&\\$1\t\c
+.\}
 ..
 .	\"LP - left aligned (block) paragraph
 .de LP

+ 119 - 0
sys/man/1/htmlroff

@@ -0,0 +1,119 @@
+.TH HTMLROFF 1
+.SH NAME
+htmlroff \- HTML formatting and typesetting
+.SH SYNOPSIS
+.B htmlroff
+[
+.B -iuv
+]
+[
+.B -m
+.I name
+]
+[
+.B -r
+.I aN
+]
+[
+.I file
+\&...
+]
+.SH DESCRIPTION
+.I Htmlroff
+accepts
+.IR troff (1)
+input in the named 
+.I files
+and formats it as HTML for viewing in a web browser.
+.PP
+If no
+.I file
+argument is given, 
+.I htmlroff
+reads the standard input.
+An argument consisting of a single minus
+.RB ( - )
+is taken to be
+a file name corresponding to the standard input.
+The options are:
+.TP
+.B -i
+Read standard input after the input files are exhausted.
+.TP
+.BI -m name
+Process the macro file
+.BI /sys/lib/tmac/tmac. name
+before the input
+.IR files .
+.TP
+.BI -r aN
+Set register
+.I a
+(one character name) to
+.IR N .
+.TP
+.B -u
+Generate UTF output.
+By default, 
+.I htmlroff
+converts Unicode runes into the corresponding
+HTML entity sequences
+.RB ( &alpha; ,
+.BR &nbsp; ,
+and so on).
+.I Htmlroff
+invokes
+.IR tcs (1)
+for the conversion.
+.TP
+.B -v
+Generate debugging output and warnings about suspicious input.
+.PD
+.PP
+Most 
+.I troff
+input files, especially those using the
+.IR ms (6)
+macros, can be used unaltered.
+In general, the macro file
+.B tmac.html
+should be processed after processing other standard macro files,
+as in 
+.B htmlroff
+.B -ms
+.BR -mhtml .
+.PP
+.IR Htmlroff (6)
+describes the changes to the input language.
+.PP
+.IR Mhtml (6)
+describes the new macros.
+.SH EXAMPLES
+Format the Plan 9 web page:
+.IP
+.EX
+cd /usr/web/plan9
+htmlroff -mhtml index.tr >index.html
+.EE
+.PP
+Format a paper:
+.IP
+.EX
+cd /sys/doc
+pic auth.ms | tbl | eqn | htmlroff -ms -mhtml >auth.html
+.EE
+.SH FILES
+.TP
+.B /sys/lib/troff/font/devutf/utfmap
+Mapping from
+.I troff
+two-character names like
+.B \e(*a
+to Unicode characters like α.
+.SH SOURCE
+.B /sys/src/cmd/htmlroff
+.SH "SEE ALSO
+.IR tcs (1),
+.IR troff (1),
+.IR htmlroff (6),
+.IR mhtml (6)

+ 6 - 0
sys/man/1/tcs

@@ -108,6 +108,9 @@ Part 8 (Hebrew)
 .B 8859-9
 Latin-5 (Finnish .. Portuguese)
 .TP
+.B html
+Unicode as encoded by HTML
+.TP
 .B koi8
 KOI-8 (GOST 19769-74)
 .TP
@@ -157,6 +160,9 @@ Unknown Kanji will be converted into
 .B 0xFFFD
 characters.
 .TP
+.B tcs -t html
+Convert UTF into character set-independent HTML.
+.TP
 .B tcs -lv
 Print an up to date list of the supported character sets.
 .SH SOURCE

+ 358 - 0
sys/man/6/htmlroff

@@ -0,0 +1,358 @@
+.TH HTMLROFF 6
+.SH NAME
+htmlroff \- HTML formatting and typesetting
+.SH DESCRIPTION
+.I Htmlroff (1)
+accepts 
+.I troff
+input with a few extensions and changes.
+This manual describes the changes to the input language,
+assuming a working knowledge of
+.I troff
+itself.
+.SS Name lengths
+.PP
+Request, macro, string, and number names can be longer
+than two letters, as in:
+.IP
+.EX
+\&.html c <center>
+\&.de footnote
+Footnote here.
+\&..
+\&.footnote
+\&.ds string "hello
+\&\e*[string]
+\&.nr number 1
+\&\en[number]
+.EE
+.SS HTML output
+.PP
+Two new requests:
+.IP
+.EX
+\&.html \fIid\fP \fR[ \fI<html>\fP ]\fL
+\&.ihtml \fIid\fP \fR[ \fI<ihtml>\fP ]\fL
+.EE
+.LP
+.B .html
+and
+.B .ihtml
+insert HTML into the output.
+The requests are only for opening new HTML tags.
+To close previously-opened tags, repeat the request
+with the same
+.IR id .
+For example, the input:
+.IP
+.EX
+\&.html t <table><tr>
+\&.html td <td>Cell 1
+\&.html td <td>Cell 2
+\&.html td
+\&.html t
+.EX
+.LP
+produces this output:
+.IP
+.EX
+<table><tr><td>Cell 1</td><td>Cell 2</td></tr></table>
+.EE
+.LP
+The
+.B .html
+request is intended for block-level HTML constructs (those that can contain
+.BR <p> )
+and maintains the HTML tag stack automatically.
+Intermediate tags need not be explicitly closed:
+removing the final
+.B \&.html t
+line in the example above would produce the same output.
+The special
+.I id
+.L -
+closes the HTML tags immediately after printing them.
+.PP
+The
+.B .ihtml
+request is similar to
+.B .html
+but is intended for inline HTML constructs such as
+.B <b>
+or
+.B <i>
+(those that can be contained
+within 
+.BR <p> ).
+Unlike
+.BR .html ,
+.B .ihtml
+treats the open HTML tags as a set rather than a stack:
+each must be explicitly closed.
+Although it treats the tags as a set, 
+.B .ihtml
+treats nesting properly in the output,
+closing and reopening tags as necessary.
+For example, the input:
+.IP
+.EX
+\&.ihtml style <b>
+\&.ihtml link <a href="link.html">
+Bold
+\&.ihtml style <i>
+and italic, still linked.
+\&.ihtml link <a>
+Unlinked.
+\&.ihtml style
+.EE
+.LP
+produces this output:
+.IP
+.EX
+<b><a href="link.html">Bold</a></b>
+<i><a href="link.html">and italic, still linked.</i></a>
+<i>Unlinked.</i>
+.EE
+.PP
+Outside of
+.B .html
+and
+.B .ihtml
+requests, the characters
+.LR < ,
+.LR > ,
+and
+.L &
+are treated as normal characters, not HTML markers,
+and are translated to
+.LR &lt; ,
+.LR &gt; ,
+and
+.L &amp;
+on output.
+To embed the raw HTML markers, use
+.LR \e< ,
+.LR \e> ,
+and
+.L \e@
+.RI [ sic ].
+.SS Font changes
+.PP
+.I Htmlroff
+interprets the usual 
+.BR \ef ,
+.BR .ft ,
+.BR \es ,
+and
+.B .ps
+requests to change the font and point size.
+After applying each such change to its internal registers,
+.I htmlroff
+invokes the
+.B .font
+macro to emit corresponding HTML.
+The default definition of
+.B .font
+is:
+.IP
+.EX
+\&.de font
+\&.ihtml f1
+\&.ihtml f
+\&.ihtml f <span style=\"font-size=\\n(.spt\">
+\&.if \\n(.f==2 .ihtml f1 <i>
+\&.if \\n(.f==3 .ihtml f1 <b>
+\&.if \\n(.f==4 .ihtml f1 <b><i>
+\&.if \\n(.f==5 .ihtml f1 <tt>
+\&.if \\n(.f==6 .ihtml f1 <tt><i>
+\&..
+.EE
+.LP
+Input files can redefine
+.B .font
+like any other request or macro.
+.SS Paragraphs
+.I Htmlroff
+implements line height, text adjustment, and margins by 
+wrapping all output text in 
+.B <p style="...">
+tags.
+This behavior can be disabled by setting the
+.B .paragraph
+number register to zero.
+Setting the
+.B .margin
+register to zero
+eliminates only the margin annotations.
+.SS Subscripts and superscripts
+.PP
+.I Htmlroff
+interprets the
+.BR \eu ,
+.BR \ed ,
+and
+.BR \ev 
+requests to move vertically during output.
+It emits output vertically offset up the page inside
+.B <sup>
+tags and output vertically offset down the page 
+inside
+.B <sub>
+tags.  
+This heuristic handles simple equations formatted by
+.IR eqn (1).
+.SS Conditional input
+.PP
+To make it easier to write input files that can be formatted by both
+.I troff
+and
+.IR htmlroff ,
+.I htmlroff
+adds a new condition
+.B h
+which evaluates true in
+.B .if
+and
+.B .ie
+requests.
+The
+.B t
+condition continues to evaluate true, to accomodate 
+input files trying to distinguish between
+.I troff
+and
+.IR nroff .
+To write a conditional matching
+.I troff
+alone, use
+.RB ` ".if !h .if t" '.
+.PP
+.I Htmlroff 's
+handling of conditional input does not match
+.IR troff 's
+exactly.
+For example,
+.IP
+.EX
+\&.if 0 \e{\e
+\&.de xx
+\&..
+\&.\e}
+.EE
+.LP
+redefines the
+.B xx
+macro in 
+.I troff
+but not in
+.IR htmlroff .
+Do not write files depending on this behavior, as this bug may be fixed
+in the future.
+.I Htmlroff
+also mishandles
+.B \e}
+in some cases.  To work around them, use
+.B .\e}
+on a line by itself, as in the last example.
+.SS Diversions
+.PP
+Diversions in 
+.I htmlroff
+use the alignment in effect at the time of the
+diversion
+when output.
+In particular,
+.IP
+.EX
+\&.di xx
+Line here.
+\&.di
+\&.nf
+\&.ce 
+\&.xx
+.EE
+.LP
+produces a centered line in 
+.I troff
+but not in 
+.IR htmlroff .
+The solution is to center inside the diversion, as in
+.IP
+.EX
+\&.di xx
+\&.if h .ce 999
+Line here
+\&.di
+.EE
+.SS Traps
+.I Htmlroff
+implements traps at vertical position 0,
+which run when the first character is about
+to be printed.
+Other position traps are ignored.
+Input traps are implemented.
+.SS Input pipes
+.PP
+.I Htmlroff
+adds a new request
+.B .inputpipe
+.I stop
+.I cmd
+that redirects
+.IR htmlroff 's
+input into a pipe to 
+.IR cmd .
+The redirection stops on encountering the line
+.IR stop ,
+optionally followed by white space and extra text.
+This is a dangerous and clusmy request, as 
+.I htmlroff
+stops interpreting its input during the redirection, so
+.I stop
+must be found in the input itself, not in a macro that
+the input might appear to call.
+Although clusmy,
+.B .inputpipe
+allows input files to invoke
+.I troff
+to handle complicated input.
+For example, 
+.B tmac.html
+redefines the
+.B PS
+macro that marks the beginning of a
+.IR pic (1)
+picture:
+.IP
+.EX
+\&.nr png -1 1
+\&.de PS
+\&.ds pngbase "\e\e*[basename]
+\&.if '\e\e*[pngbase]'' .ds pngbase \e\en(.B
+\&.ds pngfile \e\e*[pngbase]\e\en+[png].png
+\&.html - <center><img src="\e\e*[pngfile]"></center>
+\&.inputpipe .PE troff2png >\e\e*[pngfile]
+\&..
+.EE
+.LP
+This macro invokes the shell script
+.I troff2png
+to run troff and convert the Postscript
+output to a PNG image file.
+Before starting the program, the macro creates
+a new file name for the image and prints
+HTML referring to it.
+The
+.B .B
+register holds the final path element
+(the base name) of the current input file.
+.SS Unimplemented
+Tabs are set every eight spaces and cannot be changed.
+.PP
+Some requests, such as 
+.BR .tl ,
+are unimplemented for lack of a good implementation.
+Workarounds can be defined as necessary in input files.
+.SH SEE ALSO
+.IR htmlroff (1),
+.IR mhtml (6)

+ 105 - 0
sys/man/6/mhtml

@@ -0,0 +1,105 @@
+.TH MHTML 6
+.SH NAME
+mhtml \- macros for formatting HTML
+.SH SYNOPSIS
+.B pic
+.B |
+.B tbl
+.B |
+.B eqn
+.B |
+.B htmlroff
+[
+.B -man
+|
+.B -ms
+]
+.B -mhtml
+.I file
+\&...
+.SH DESCRIPTION
+This package of
+.IR htmlroff (1)
+macro definitions provides convenient macros for formatting HTML.
+It is usually used along with 
+.I troff (1)
+macro packages such as
+.IR man (6)
+and
+.IR ms (6).
+.I Mhtml
+replaces some macros defined in the other packages,
+so it should be listed after them on the
+.I htmlroff 
+command line.
+.PP
+The following macros are defined:
+.TP
+.B .HTML \fItitle
+Print an HTML header marking the output as 
+HTML 4.01 loose transitional encoded in UTF.
+If given, the
+.I title
+is printed inside
+.B <title>
+tags.
+This macro opens the
+.B <html>
+tag, opens and closes the
+.B <head>
+section, and opens
+.B <body> .
+It invokes the
+.B .HEAD
+macro inside the
+.B <head>
+section.
+To add arbitrary lines to the header,
+append to
+.B .HEAD
+before invoking
+.BR .HTML .
+.TP
+.B .FS\fR, \fP.FE
+Accumulate footnotes and print them at the end of the
+document under a \fBNotes\fP heading.
+These replace the macros in
+.IR ms (6).
+To emit the notes accumulated so far, invoke
+.BR .NOTES .
+.TP
+.B .PS\fR, \fP.PE
+Replace input bracketed
+.B .PS
+and
+.B .PE
+with a PNG image corresponding to the output of
+running
+.I troff(1)
+on the input.
+.TP
+.B .TS\fR, \fP.TE
+Identical to
+.B .PS
+and
+.BR .PE .
+.TP
+.B .B1 \fImargin\fP \fIwidth\fR, \fL.B2
+Format the input between
+.B .B1
+and
+.B .B2
+inside a box, with
+.I margin
+(default 10)
+pixels between the box and the text.
+The box is set to be
+.I width
+(default 60)
+percent of the current output width.
+.SH FILES
+.B /sys/lib/tmac/tmac.html
+.SH  SEE ALSO
+.IR htmlroff (1),
+.IR htmlroff (6),
+.IR ms (6)

+ 148 - 0
sys/src/cmd/htmlroff/a.h

@@ -0,0 +1,148 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <ctype.h>
+
+enum
+{
+	Unbsp = 0x00A0,
+	Uprivate = 0xF000,
+	Uempty,	/* \& */
+	Uamp,	/* raw & */
+	Ult,		/* raw < */
+	Ugt,		/* raw > */
+	Utick,	/* raw ' */
+	Ubtick,	/* raw ` */
+	Uminus,	/* raw - */
+	Uspace,	/* raw space */
+	Upl,		/* symbol + */
+	Ueq,		/* symbol = */
+	Umi,		/* symbol - */
+	Uformatted,	/* start diverted output */
+	Uunformatted,	/* end diverted output */
+
+	UPI = 720,	/* units per inch */
+	UPX = 10,	/* units per pixel */
+	
+	/* special input modes */
+	CopyMode = 1<<1,
+	ExpandMode = 1<<2,
+	ArgMode = 1<<3,
+	HtmlMode = 1<<4,
+	
+	MaxLine = 1024,
+};
+
+Rune*	L(char*);
+
+void		addesc(Rune, int (*)(void), int);
+void		addraw(Rune*, void(*)(Rune*));
+void		addreq(Rune*, void(*)(int, Rune**), int);
+void		af(Rune*, Rune*);
+void		as(Rune*, Rune*);
+void		br(void);
+void		closehtml(void);
+Rune*	copyarg(void);
+void		delraw(Rune*);
+void		delreq(Rune*);
+void		ds(Rune*, Rune*);
+int		dv(int);
+int		e_nop(void);
+int		e_warn(void);
+void*	emalloc(uint);
+void*	erealloc(void*, uint);
+Rune*	erunesmprint(char*, ...);
+Rune*	erunestrdup(Rune*);
+char*	esmprint(char*, ...);
+char*	estrdup(char*);
+int		eval(Rune*);
+int		evalscale(Rune*, int);
+Rune*	getname(void);
+int		getnext(void);
+Rune*	getds(Rune*);
+Rune*	_getnr(Rune*);
+int		getnr(Rune*);
+int		getnrr(Rune*);
+int		getrune(void);
+Rune*	getqarg(void);
+Rune*	getline(void);
+void		hideihtml(void);
+void		html(Rune*, Rune*);
+void		htmlinit(void);
+void		ihtml(Rune*, Rune*);
+void		inputnotify(void(*)(void));
+void		itrap(void);
+void		itrapset(void);
+int		linefmt(Fmt*);
+void		nr(Rune*, int);
+void		_nr(Rune*, Rune*);
+void		out(Rune*);
+void		(*outcb)(Rune);
+void		outhtml(Rune*);
+void		outrune(Rune);
+void		outtrap(void);
+int		popinput(void);
+void		printds(int);
+int		pushinputfile(Rune*);
+void		pushinputstring(Rune*);
+int		pushstdin(void);
+int		queueinputfile(Rune*);
+int		queuestdin(void);
+void		r_nop(int, Rune**);
+void		r_warn(int, Rune**);
+Rune	*readline(int);
+void		reitag(void);
+void		renraw(Rune*, Rune*);
+void		renreq(Rune*, Rune*);
+void		run(void);
+void		runinput(void);
+int		runmacro(int, int, Rune**);
+void		runmacro1(Rune*);
+Rune*	rune2html(Rune);
+void		setlinenumber(Rune*, int);
+void		showihtml(void);
+void		sp(int);
+void		t1init(void);
+void		t2init(void);
+void		t3init(void);
+void		t4init(void);
+void		t5init(void);
+void		t6init(void);
+void		t7init(void);
+void		t8init(void);
+void		t9init(void);
+void		t10init(void);
+void		t11init(void);
+void		t12init(void);
+void		t13init(void);
+void		t14init(void);
+void		t15init(void);
+void		t16init(void);
+void		t17init(void);
+void		t18init(void);
+void		t19init(void);
+void		t20init(void);
+Rune	troff2rune(Rune*);
+void		unfont(void);
+void		ungetnext(Rune);
+void		ungetrune(Rune);
+void		unitag(void);
+void		warn(char*, ...);
+
+extern	int		backslash;
+extern	int		bol;
+extern	Biobuf	bout;
+extern	int		broke;
+extern	int		dot;
+extern	int		inputmode;
+extern	int		inrequest;
+extern	int		tick;
+extern	int		utf8;
+extern	int		verbose;
+extern	int		linepos;
+
+#define	runemalloc(n)	(Rune*)emalloc((n)*sizeof(Rune))
+#define	runerealloc(r, n)	(Rune*)erealloc(r, (n)*sizeof(Rune))
+#define	runemove(a, b, n)	memmove(a, b, (n)*sizeof(Rune))
+
+#pragma varargck type "L" void

+ 116 - 0
sys/src/cmd/htmlroff/char.c

@@ -0,0 +1,116 @@
+#include "a.h"
+
+/*
+ * Translate Unicode to HTML by asking tcs(1).
+ * This way we don't have yet another table.
+ */
+Rune*
+rune2html(Rune r)
+{
+	static Biobuf b;
+	static int fd = -1;
+	static Rune **tcscache[256];
+	int p[2];
+	char *q;
+	
+	if(r == '\n')
+		return L("\n");
+
+	if(tcscache[r>>8] && tcscache[r>>8][r&0xFF])
+		return tcscache[r>>8][r&0xFF];
+
+	if(fd < 0){
+		if(pipe(p) < 0)
+			sysfatal("pipe: %r");
+		switch(fork()){
+		case -1:
+			sysfatal("fork: %r");
+		case 0:
+			dup(p[0], 0);
+			dup(p[0], 1);
+			close(p[1]);
+			execl("/bin/tcs", "tcs", "-t", "html", nil);
+			_exits(0);
+		default:
+			close(p[0]);
+			fd = p[1];
+			Binit(&b, fd, OREAD);
+			break;
+		}
+	}
+	fprint(fd, "%C\n", r);
+	q = Brdline(&b, '\n');
+	if(q == nil)
+		sysfatal("tcs: early eof");
+	q[Blinelen(&b)-1] = 0;
+	if(tcscache[r>>8] == nil)
+		tcscache[r>>8] = emalloc(256*sizeof tcscache[0][0]);
+	tcscache[r>>8][r&0xFF] = erunesmprint("%s", q);
+	return tcscache[r>>8][r&0xFF];
+}
+
+/*
+ * Translate troff to Unicode by looking in troff's utfmap.
+ * This way we don't have yet another hard-coded table.
+ */
+typedef struct Trtab Trtab;
+struct Trtab
+{
+	char t[3];
+	Rune r;
+};
+
+static Trtab trtab[200];
+int ntrtab;
+
+static Trtab trinit[] =
+{
+	"pl",		Upl,
+	"eq",	Ueq,
+	"em",	0x2014,
+	"en",	0x2013,
+	"mi",	Umi,
+	"fm",	0x2032,
+};
+
+Rune
+troff2rune(Rune *rs)
+{
+	char *file, *f[10], *p, s[3];
+	int i, nf;
+	Biobuf *b;
+	
+	if(rs[0] >= Runeself || rs[1] >= Runeself)
+		return Runeerror;
+	s[0] = rs[0];
+	s[1] = rs[1];
+	s[2] = 0;
+	if(ntrtab == 0){
+		for(i=0; i<nelem(trinit) && ntrtab < nelem(trtab); i++){
+			trtab[ntrtab] = trinit[i];
+			ntrtab++;
+		}
+		file = "/sys/lib/troff/font/devutf/utfmap";
+		if((b = Bopen(file, OREAD)) == nil)
+			sysfatal("open %s: %r", file);
+		while((p = Brdline(b, '\n')) != nil){
+			p[Blinelen(b)-1] = 0;
+			nf = getfields(p, f, nelem(f), 0, "\t");
+			for(i=0; i+2<=nf && ntrtab<nelem(trtab); i+=2){
+				chartorune(&trtab[ntrtab].r, f[i]);
+				memmove(trtab[ntrtab].t, f[i+1], 2);
+				ntrtab++;
+			}
+		}
+		Bterm(b);
+		
+		if(ntrtab >= nelem(trtab))
+			fprint(2, "%s: trtab too small\n", argv0);
+	}
+	
+	for(i=0; i<ntrtab; i++)
+		if(strcmp(s, trtab[i].t) == 0)
+			return trtab[i].r;
+	return Runeerror;
+}
+

+ 287 - 0
sys/src/cmd/htmlroff/html.c

@@ -0,0 +1,287 @@
+/*
+ * Emit html.  Keep track of tags so that user doesn't have to.
+ */
+
+#include "a.h"
+
+typedef struct Tag Tag;
+struct Tag
+{
+	Tag *next;
+	Rune *id;
+	Rune *open;
+	Rune *close;
+};
+
+Tag *tagstack;
+Tag *tagset;
+int hidingset;
+
+static Rune*
+closingtag(Rune *s)
+{
+	Rune *t;
+	Rune *p0, *p;
+	
+	t = runemalloc(sizeof(Rune));
+	if(s == nil)
+		return t;
+	for(p=s; *p; p++){
+		if(*p == Ult){
+			p++;
+			if(*p == '/'){
+				while(*p && *p != Ugt)
+					p++;
+				goto close;
+			}
+			p0 = p;
+			while(*p && !isspacerune(*p) && *p != Uspace && *p != Ugt)
+				p++;
+			t = runerealloc(t, 1+(p-p0)+2+runestrlen(t)+1);
+			runemove(t+(p-p0)+3, t, runestrlen(t)+1);
+			t[0] = Ult;
+			t[1] = '/';
+			runemove(t+2, p0, p-p0);
+			t[2+(p-p0)] = Ugt;
+		}
+		
+		if(*p == Ugt && p>s && *(p-1) == '/'){
+		close:
+			for(p0=t+1; *p0 && *p0 != Ult; p0++)
+				;
+			runemove(t, p0, runestrlen(p0)+1);
+		}
+	}
+	return t;	
+}
+
+void
+html(Rune *id, Rune *s)
+{
+	Rune *es;
+	Tag *t, *tt, *next;
+
+	br();
+	hideihtml();	/* br already did, but be paranoid */
+	for(t=tagstack; t; t=t->next){
+		if(runestrcmp(t->id, id) == 0){
+			for(tt=tagstack;; tt=next){
+				next = tt->next;
+				free(tt->id);
+				free(tt->open);
+				out(tt->close);
+				outrune('\n');
+				free(tt->close);
+				free(tt);
+				if(tt == t){
+					tagstack = next;
+					goto cleared;
+				}
+			}
+		}
+	}
+
+cleared:
+	if(s == nil || s[0] == 0)
+		return;
+	out(s);
+	outrune('\n');
+	es = closingtag(s);
+	if(es[0] == 0){
+		free(es);
+		return;
+	}
+	if(runestrcmp(id, L("-")) == 0){
+		out(es);
+		outrune('\n');
+		free(es);
+		return;
+	}
+	t = emalloc(sizeof *t);
+	t->id = erunestrdup(id);
+	t->close = es;
+	t->next = tagstack;
+	tagstack = t;
+}
+
+void
+closehtml(void)
+{
+	Tag *t, *next;
+	
+	br();
+	hideihtml();
+	for(t=tagstack; t; t=next){
+		next = t->next;
+		out(t->close);
+		outrune('\n');
+		free(t->id);
+		free(t->close);
+		free(t);
+	}
+}
+
+static void
+rshow(Tag *t, Tag *end)
+{
+	if(t == nil || t == end)
+		return;
+	rshow(t->next, end);
+	out(t->open);
+}
+
+void
+ihtml(Rune *id, Rune *s)
+{
+	Tag *t, *tt, **l;
+
+	for(t=tagset; t; t=t->next){
+		if(runestrcmp(t->id, id) == 0){
+			if(s && t->open && runestrcmp(t->open, s) == 0)
+				return;
+			for(l=&tagset; (tt=*l); l=&tt->next){
+				if(!hidingset)
+					out(tt->close);
+				if(tt == t)
+					break;
+			}
+			*l = t->next;
+			free(t->id);
+			free(t->close);
+			free(t->open);
+			free(t);
+			if(!hidingset)
+				rshow(tagset, *l);
+			goto cleared;
+		}
+	}
+
+cleared:
+	if(s == nil || s[0] == 0)
+		return;
+	t = emalloc(sizeof *t);
+	t->id = erunestrdup(id);
+	t->open = erunestrdup(s);
+	t->close = closingtag(s);
+	if(!hidingset)
+		out(s);
+	t->next = tagset;
+	tagset = t;
+}
+
+void
+hideihtml(void)
+{
+	Tag *t;
+
+	if(hidingset)
+		return;
+	hidingset = 1;
+	for(t=tagset; t; t=t->next)
+		out(t->close);
+}
+
+void
+showihtml(void)
+{
+	if(!hidingset)
+		return;
+	hidingset = 0;
+	rshow(tagset, nil);
+}
+
+int
+e_lt(void)
+{
+	return Ult;
+}
+
+int
+e_gt(void)
+{
+	return Ugt;
+}
+
+int
+e_at(void)
+{
+	return Uamp;
+}
+
+int
+e_tick(void)
+{
+	return Utick;
+}
+
+int
+e_btick(void)
+{
+	return Ubtick;
+}
+
+int
+e_minus(void)
+{
+	return Uminus;
+}
+
+void
+r_html(Rune *name)
+{
+	Rune *id, *line, *p;
+	
+	id = copyarg();
+	line = readline(HtmlMode);
+	for(p=line; *p; p++){
+		switch(*p){
+		case '<':
+			*p = Ult;
+			break;
+		case '>':
+			*p = Ugt;
+			break;
+		case '&':
+			*p = Uamp;
+			break;
+		case ' ':
+			*p = Uspace;
+			break;
+		}
+	}
+	if(name[0] == 'i')
+		ihtml(id, line);
+	else
+		html(id, line);
+	free(id);
+	free(line);
+}
+
+char defaultfont[] =
+	".ihtml f1\n"
+	".ihtml f\n"
+	".ihtml f <span style=\"font-size=\\n(.spt\">\n"
+	".if \\n(.f==2 .ihtml f1 <i>\n"
+	".if \\n(.f==3 .ihtml f1 <b>\n"
+	".if \\n(.f==4 .ihtml f1 <b><i>\n"
+	".if \\n(.f==5 .ihtml f1 <tt>\n"
+	".if \\n(.f==6 .ihtml f1 <tt><i>\n"
+	"..\n"
+;
+
+void
+htmlinit(void)
+{
+	addraw(L("html"), r_html);
+	addraw(L("ihtml"), r_html);
+
+	addesc('<', e_lt, CopyMode);
+	addesc('>', e_gt, CopyMode);
+	addesc('\'', e_tick, CopyMode);
+	addesc('`', e_btick, CopyMode);
+	addesc('-', e_minus, CopyMode);
+	addesc('@', e_at, CopyMode);
+	
+	ds(L("font"), L(defaultfont));
+}
+

+ 241 - 0
sys/src/cmd/htmlroff/input.c

@@ -0,0 +1,241 @@
+/*
+ * Read input files.
+ */
+#include "a.h"
+
+typedef struct Istack Istack;
+struct Istack
+{
+	Rune unget[3];
+	int nunget;
+	Biobuf *b;
+	Rune *p;
+	Rune *ep;
+	Rune *s;
+	int lineno;
+	Rune *name;
+	Istack *next;
+	void (*fn)(void);
+};
+
+Istack *istack;
+Istack *ibottom;
+
+static void
+setname(void)
+{
+	Rune *r, *p;
+
+	if(istack == nil || istack->name == nil)
+		return;
+	_nr(L(".F"), istack->name);
+	r = erunestrdup(istack->name);
+	p = runestrchr(r, '.');
+	if(p)
+		*p = 0;
+	_nr(L(".B"), r);
+	free(r);
+}
+
+static void
+ipush(Istack *is)
+{
+	if(istack == nil)
+		ibottom = is;
+	else
+		is->next = istack;
+	istack = is;
+	setname();
+}
+
+static void
+iqueue(Istack *is)
+{
+	if(ibottom == nil){
+		istack = is;
+		setname();
+	}else
+		ibottom->next = is;
+	ibottom = is;
+}
+
+int
+_inputfile(Rune *s, void (*push)(Istack*))
+{
+	Istack *is;
+	Biobuf *b;
+	char *t;
+	
+	t = esmprint("%S", s);
+	if((b = Bopen(t, OREAD)) == nil){
+		free(t);
+		fprint(2, "%s: open %S: %r\n", argv0, s);
+		return -1;
+	}
+	free(t);
+	is = emalloc(sizeof *is);
+	is->b = b;
+	is->name = erunestrdup(s);
+	is->lineno = 1;
+	push(is);
+	return 0;
+}
+
+int
+pushinputfile(Rune *s)
+{
+	return _inputfile(s, ipush);
+}
+
+int
+queueinputfile(Rune *s)
+{
+	return _inputfile(s, iqueue);
+}
+
+int
+_inputstdin(void (*push)(Istack*))
+{	
+	Biobuf *b;
+	Istack *is;
+
+	if((b = Bopen("/dev/null", OREAD)) == nil){
+		fprint(2, "%s: open /dev/null: %r\n", argv0);
+		return -1;
+	}
+	dup(0, b->fid);
+	is = emalloc(sizeof *is);
+	is->b = b;
+	is->name = erunestrdup(L("stdin"));
+	is->lineno = 1;
+	push(is);
+	return 0;
+}
+
+int
+pushstdin(void)
+{
+	return _inputstdin(ipush);
+}
+
+int
+queuestdin(void)
+{
+	return _inputstdin(iqueue);
+}
+
+void
+_inputstring(Rune *s, void (*push)(Istack*))
+{
+	Istack *is;
+	
+	is = emalloc(sizeof *is);
+	is->s = erunestrdup(s);
+	is->p = is->s;
+	is->ep = is->p+runestrlen(is->p);
+	push(is);
+}
+
+void
+pushinputstring(Rune *s)
+{
+	_inputstring(s, ipush);
+}
+
+
+void
+inputnotify(void (*fn)(void))
+{
+	if(istack)
+		istack->fn = fn;
+}
+
+int
+popinput(void)
+{
+	Istack *is;
+
+	is = istack;
+	if(is == nil)
+		return 0;
+
+	istack = istack->next;
+	if(is->b)
+		Bterm(is->b);
+	free(is->s);
+	free(is->name);
+	if(is->fn)
+		is->fn();
+	free(is);
+	setname();
+	return 1;
+}
+
+int
+getrune(void)
+{
+	Rune r;
+	int c;
+	
+top:
+	if(istack == nil)
+		return -1;
+	if(istack->nunget)
+		return istack->unget[--istack->nunget];
+	else if(istack->p){
+		if(istack->p >= istack->ep){
+			popinput();
+			goto top;
+		}
+		r = *istack->p++;
+	}else if(istack->b){
+		if((c = Bgetrune(istack->b)) < 0){
+			popinput();
+			goto top;
+		}
+		r = c;
+	}else{
+		r = 0;
+		sysfatal("getrune - can't happen");
+	}
+	if(r == '\n')
+		istack->lineno++;	
+	return r;
+}
+
+void
+ungetrune(Rune r)
+{
+	if(istack == nil || istack->nunget >= nelem(istack->unget))
+		pushinputstring(L(""));
+	istack->unget[istack->nunget++] = r;
+}
+
+int
+linefmt(Fmt *f)
+{
+	Istack *is;
+	
+	for(is=istack; is && !is->b; is=is->next)
+		;
+	if(is)
+		return fmtprint(f, "%S:%d", is->name, is->lineno);
+	else
+		return fmtprint(f, "<no input>");
+}
+
+void
+setlinenumber(Rune *s, int n)
+{
+	Istack *is;
+	
+	for(is=istack; is && !is->name; is=is->next)
+		;
+	if(is){
+		if(s){
+			free(is->name);
+			is->name = erunestrdup(s);
+		}
+		is->lineno = n;
+	}
+}

+ 72 - 0
sys/src/cmd/htmlroff/main.c

@@ -0,0 +1,72 @@
+/*
+ * Convert troff -ms input to HTML.
+ */
+
+#include "a.h"
+
+Biobuf	bout;
+char*	tmacdir;
+int		verbose;
+int		utf8 = 0;
+
+void
+usage(void)
+{
+	fprint(2, "usage: htmlroff [-iuv] [-m mac] [-r an] [file...]\n");
+	exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+	int i, dostdin;
+	char *p;
+	Rune *r;
+	Rune buf[2];
+	
+	Binit(&bout, 1, OWRITE);
+	fmtinstall('L', linefmt);
+	quotefmtinstall();
+	
+	tmacdir = "/sys/lib/tmac";
+	dostdin = 0;
+	ARGBEGIN{
+	case 'i':
+		dostdin = 1;
+		break;
+	case 'm':
+		r = erunesmprint("%s/tmac.%s", tmacdir, EARGF(usage()));
+		if(queueinputfile(r) < 0)
+			fprint(2, "%S: %r\n", r);
+		break;
+	case 'r':
+		p = EARGF(usage());
+		p += chartorune(buf, p);
+		buf[1] = 0;
+		_nr(buf, erunesmprint("%s", p+1));
+		break;
+	case 'u':
+		utf8 = 1;
+		break;
+	case 'v':
+		verbose = 1;
+		break;
+	default:
+		usage();
+	}ARGEND
+
+	for(i=0; i<argc; i++){
+		if(strcmp(argv[i], "-") == 0)
+			queuestdin();
+		else
+			queueinputfile(erunesmprint("%s", argv[i]));
+	}
+	if(argc == 0 || dostdin)
+		queuestdin();
+	
+	run();
+	Bprint(&bout, "\n");
+	Bterm(&bout);
+	exits(nil);
+}
+

+ 38 - 0
sys/src/cmd/htmlroff/mkfile

@@ -0,0 +1,38 @@
+</$objtype/mkfile
+
+TARG=htmlroff
+
+OFILES=\
+	char.$O\
+	html.$O\
+	input.$O\
+	main.$O\
+	roff.$O\
+	t1.$O\
+	t2.$O\
+	t3.$O\
+	t4.$O\
+	t5.$O\
+	t6.$O\
+	t7.$O\
+	t8.$O\
+#	t9.$O\
+	t10.$O\
+	t11.$O\
+#	t12.$O\
+	t13.$O\
+	t14.$O\
+	t15.$O\
+	t16.$O\
+	t17.$O\
+	t18.$O\
+	t19.$O\
+	t20.$O\
+	util.$O\
+
+HFILES=a.h
+
+BIN=/$objtype/bin
+
+</sys/src/cmd/mkone
+

+ 750 - 0
sys/src/cmd/htmlroff/roff.c

@@ -0,0 +1,750 @@
+#include "a.h"
+
+enum
+{
+	MAXREQ = 100,
+	MAXRAW = 40,
+	MAXESC = 60,
+	MAXLINE = 1024,
+	MAXIF = 20,
+	MAXARG = 10,
+};
+
+typedef struct Esc Esc;
+typedef struct Req Req;
+typedef struct Raw Raw;
+
+/* escape sequence handler, like for \c */
+struct Esc
+{
+	Rune r;
+	int (*f)(void);
+	int mode;
+};
+
+/* raw request handler, like for .ie */
+struct Raw
+{
+	Rune *name;
+	void (*f)(Rune*);
+};
+
+/* regular request handler, like for .ft */
+struct Req
+{
+	int argc;
+	Rune *name;
+	void (*f)(int, Rune**);
+};
+
+int		dot = '.';
+int		tick = '\'';
+int		backslash = '\\';
+
+int		inputmode;
+Req		req[MAXREQ];
+int		nreq;
+Raw		raw[MAXRAW];
+int		nraw;
+Esc		esc[MAXESC];
+int		nesc;
+int		iftrue[MAXIF];
+int		niftrue;
+
+int isoutput;
+int linepos;
+
+
+void
+addraw(Rune *name, void (*f)(Rune*))
+{
+	Raw *r;
+	
+	if(nraw >= nelem(raw)){
+		fprint(2, "too many raw requets\n");
+		return;
+	}
+	r = &raw[nraw++];
+	r->name = erunestrdup(name);
+	r->f = f;
+}
+
+void
+delraw(Rune *name)
+{
+	int i;
+	
+	for(i=0; i<nraw; i++){
+		if(runestrcmp(raw[i].name, name) == 0){
+			if(i != --nraw){
+				free(raw[i].name);
+				raw[i] = raw[nraw];
+			}
+			return;
+		}
+	}
+}
+
+void
+renraw(Rune *from, Rune *to)
+{
+	int i;
+	
+	delraw(to);
+	for(i=0; i<nraw; i++)
+		if(runestrcmp(raw[i].name, from) == 0){
+			free(raw[i].name);
+			raw[i].name = erunestrdup(to);
+			return;
+		}
+}
+
+
+void
+addreq(Rune *s, void (*f)(int, Rune**), int argc)
+{
+	Req *r;
+
+	if(nreq >= nelem(req)){
+		fprint(2, "too many requests\n");
+		return;
+	}
+	r = &req[nreq++];
+	r->name = erunestrdup(s);
+	r->f = f;
+	r->argc = argc;
+}
+
+void
+delreq(Rune *name)
+{
+	int i;
+
+	for(i=0; i<nreq; i++){
+		if(runestrcmp(req[i].name, name) == 0){
+			if(i != --nreq){
+				free(req[i].name);
+				req[i] = req[nreq];
+			}
+			return;
+		}
+	}
+}
+
+void
+renreq(Rune *from, Rune *to)
+{
+	int i;
+	
+	delreq(to);
+	for(i=0; i<nreq; i++)
+		if(runestrcmp(req[i].name, from) == 0){
+			free(req[i].name);
+			req[i].name = erunestrdup(to);
+			return;
+		}
+}
+
+void
+addesc(Rune r, int (*f)(void), int mode)
+{
+	Esc *e;
+	
+	if(nesc >= nelem(esc)){
+		fprint(2, "too many escapes\n");
+		return;
+	}
+	e = &esc[nesc++];
+	e->r = r;
+	e->f = f;
+	e->mode = mode;
+}
+
+/*
+ * Get the next logical character in the input stream.
+ */
+int
+getnext(void)
+{
+	int i, r;
+
+next:
+	r = getrune();
+	if(r < 0)
+		return -1;
+	if(r == Uformatted){
+		br();
+		assert(!isoutput);
+		while((r = getrune()) >= 0 && r != Uunformatted){
+			if(r == Uformatted)
+				continue;
+			outrune(r);
+		}
+		goto next;
+	}
+	if(r == Uunformatted)
+		goto next;
+	if(r == backslash){
+		r = getrune();
+		if(r < 0)
+			return -1;
+		for(i=0; i<nesc; i++){
+			if(r == esc[i].r && (inputmode&esc[i].mode)==inputmode){
+				if(esc[i].f == e_warn)
+					warn("ignoring %C%C", backslash, r);
+				r = esc[i].f();
+				if(r <= 0)
+					goto next;
+				return r;
+			}
+		}
+		if(inputmode&(ArgMode|CopyMode)){
+			ungetrune(r);
+			r = backslash;
+		}
+	}
+	return r;
+}
+
+void
+ungetnext(Rune r)
+{
+	/*
+	 * really we want to undo the getrunes that led us here,
+	 * since the call after ungetnext might be getrune!
+	 */
+	ungetrune(r);
+}
+
+int
+_readx(Rune *p, int n, int nmode, int line)
+{
+	int c, omode;
+	Rune *e;
+
+	while((c = getrune()) == ' ' || c == '\t')
+		;
+	ungetrune(c);
+	omode = inputmode;
+	inputmode = nmode;
+	e = p+n-1;
+	for(c=getnext(); p<e; c=getnext()){
+		if(c < 0)
+			break;
+		if(!line && (c == ' ' || c == '\t'))
+			break;
+		if(c == '\n'){
+			if(!line)
+				ungetnext(c);
+			break;
+		}
+		*p++ = c;
+	}
+	inputmode = omode;
+	*p = 0;
+	if(c < 0)
+		return -1;
+	return 0;
+}
+
+/*
+ * Get the next argument from the current line.
+ */
+Rune*
+copyarg(void)
+{
+	static Rune buf[MaxLine];
+	int c;
+	Rune *r;
+	
+	if(_readx(buf, sizeof buf, ArgMode, 0) < 0)
+		return nil;
+	r = runestrstr(buf, L("\\\""));
+	if(r){
+		*r = 0;
+		while((c = getrune()) >= 0 && c != '\n')
+			;
+		ungetrune('\n');
+	}
+	r = erunestrdup(buf);	
+	return r;
+}
+
+/*
+ * Read the current line in given mode.  Newline not kept.
+ * Uses different buffer from copyarg!
+ */
+Rune*
+readline(int m)
+{
+	static Rune buf[MaxLine];
+	Rune *r;
+
+	if(_readx(buf, sizeof buf, m, 1) < 0)
+		return nil;
+	r = erunestrdup(buf);
+	return r;
+}
+
+/*
+ * Given the argument line (already read in copy+arg mode),
+ * parse into arguments.  Note that \" has been left in place
+ * during copy+arg mode parsing, so comments still need to be stripped.
+ */
+int
+parseargs(Rune *p, Rune **argv)
+{
+	int argc;
+	Rune *w;
+
+	for(argc=0; argc<MAXARG; argc++){
+		while(*p == ' ' || *p == '\t')
+			p++;
+		if(*p == 0)
+			break;
+		argv[argc] = p;
+		if(*p == '"'){
+			/* quoted argument */
+			if(*(p+1) == '"'){
+				/* empty argument */
+				*p = 0;
+				p += 2;
+			}else{
+				/* parse quoted string */
+				w = p++;
+				for(; *p; p++){
+					if(*p == '"' && *(p+1) == '"')
+						*w++ = '"';
+					else if(*p == '"'){
+						p++;
+						break;
+					}else
+						*w++ = *p;
+				}
+				*w = 0;
+			}	
+		}else{
+			/* unquoted argument - need to watch out for \" comment */
+			for(; *p; p++){
+				if(*p == ' ' || *p == '\t'){
+					*p++ = 0;
+					break;
+				}
+				if(*p == '\\' && *(p+1) == '"'){
+					*p = 0;
+					if(p != argv[argc])
+						argc++;
+					return argc;
+				}
+			}
+		}
+	}
+	return argc;
+}
+
+/*
+ * Process a dot line.  The dot has been read.
+ */
+void
+dotline(int dot)
+{
+	int argc, i;
+	Rune *a, *argv[1+MAXARG];
+
+	/*
+	 * Read request/macro name
+	 */
+	a = copyarg();
+	if(a == nil || a[0] == 0){
+		free(a);
+		getrune();	/* \n */
+		return;
+	}
+	argv[0] = a;
+	/*
+	 * Check for .if, .ie, and others with special parsing.
+	 */
+	for(i=0; i<nraw; i++){
+		if(runestrcmp(raw[i].name, a) == 0){
+			raw[i].f(raw[i].name);
+			free(a);
+			return;
+		}	
+	}
+
+	/*
+	 * Read rest of line in copy mode, invoke regular request.
+	 */
+	a = readline(ArgMode);
+	if(a == nil){
+		free(argv[0]);
+		return;
+	}
+	argc = 1+parseargs(a, argv+1);
+	for(i=0; i<nreq; i++){
+		if(runestrcmp(req[i].name, argv[0]) == 0){
+			if(req[i].argc != -1){
+				if(argc < 1+req[i].argc){
+					warn("not enough arguments for %C%S", dot, req[i].name);
+					free(argv[0]);
+					free(a);
+					return;
+				}
+				if(argc > 1+req[i].argc)
+					warn("too many arguments for %C%S", dot, req[i].name);
+			}
+			req[i].f(argc, argv);
+			free(argv[0]);
+			free(a);
+			return;
+		}
+	}
+
+	/*
+	 * Invoke user-defined macros.
+	 */
+	runmacro(dot, argc, argv);
+	free(argv[0]);
+	free(a);
+}
+
+/*
+ * newlines are magical in various ways.
+ */
+int bol;
+void
+newline(void)
+{
+	int n;
+
+	if(bol)
+		sp(eval(L("1v")));
+	bol = 1;
+	if((n=getnr(L(".ce"))) > 0){
+		nr(L(".ce"), n-1);
+		br();
+	}
+	if(getnr(L(".fi")) == 0)
+		br();
+	outrune('\n');
+}
+
+void
+startoutput(void)
+{
+	char *align;
+	double ps, vs, lm, rm, ti;
+	Rune buf[200];
+
+	if(isoutput)
+		return;
+	isoutput = 1;
+
+	if(getnr(L(".paragraph")) == 0)
+		return;
+
+	nr(L(".ns"), 0);
+	isoutput = 1;
+	ps = getnr(L(".s"));
+	if(ps <= 1)
+		ps = 10;
+	ps /= 72.0;
+	USED(ps);
+
+	vs = getnr(L(".v"))*getnr(L(".ls")) * 1.0/UPI;
+	vs /= (10.0/72.0);	/* ps */
+	if(vs == 0)
+		vs = 1.2;
+
+	lm = (getnr(L(".o"))+getnr(L(".i"))) * 1.0/UPI;
+	ti = getnr(L(".ti")) * 1.0/UPI;
+	nr(L(".ti"), 0);
+
+	rm = 8.0 - getnr(L(".l"))*1.0/UPI - getnr(L(".o"))*1.0/UPI;
+	if(rm < 0)
+		rm = 0;
+	switch(getnr(L(".j"))){
+	default:
+	case 0:
+		align = "left";
+		break;
+	case 1:
+		align = "justify";
+		break;
+	case 3:
+		align = "center";
+		break;
+	case 5:
+		align = "right";
+		break;
+	}
+	if(getnr(L(".ce")))
+		align = "center";
+	if(!getnr(L(".margin")))
+		runesnprint(buf, nelem(buf), "<p style=\"line-height: %.1fem; text-indent: %.2fin; margin-top: 0; margin-bottom: 0; text-align: %s;\">\n",
+			vs, ti, align);
+	else
+		runesnprint(buf, nelem(buf), "<p style=\"line-height: %.1fem; margin-left: %.2fin; text-indent: %.2fin; margin-right: %.2fin; margin-top: 0; margin-bottom: 0; text-align: %s;\">\n",
+			vs, lm, ti, rm, align);
+	outhtml(buf);
+}
+void
+br(void)
+{
+	if(!isoutput)
+		return;
+	isoutput = 0;
+
+	nr(L(".dv"), 0);
+	dv(0);
+	hideihtml();
+	if(getnr(L(".paragraph")))
+		outhtml(L("</p>"));
+}
+
+void
+r_margin(int argc, Rune **argv)
+{
+	USED(argc);
+
+	nr(L(".margin"), eval(argv[1]));
+}
+
+int inrequest;
+void
+runinput(void)
+{
+	int c;
+	
+	bol = 1;
+	for(;;){
+		c = getnext();
+		if(c < 0)
+			break;
+		if((c == dot || c == tick) && bol){
+			inrequest = 1;
+			dotline(c);
+			bol = 1;
+			inrequest = 0;
+		}else if(c == '\n'){
+			newline();
+			itrap();
+			linepos = 0;
+		}else{
+			outtrap();
+			startoutput();
+			showihtml();
+			if(c == '\t'){
+				/* XXX do better */
+				outrune(' ');
+				while(++linepos%4)
+					outrune(' ');
+			}else{
+				outrune(c);
+				linepos++;
+			}
+			bol = 0;
+		}
+	}
+}
+
+void
+run(void)
+{
+	t1init();
+	t2init();
+	t3init();
+	t4init();
+	t5init();
+	t6init();
+	t7init();
+	t8init();
+	/* t9init(); t9.c */
+	t10init();
+	t11init();
+	/* t12init(); t12.c */
+	t13init();
+	t14init();
+	t15init();
+	t16init();
+	t17init();
+	t18init();
+	t19init();
+	t20init();
+	htmlinit();
+	hideihtml();
+	
+	addreq(L("margin"), r_margin, 1);
+	nr(L(".margin"), 1);
+	nr(L(".paragraph"), 1);
+
+	runinput();
+	while(popinput())
+		;
+	dot = '.';
+	if(verbose)
+		fprint(2, "eof\n");
+	runmacro1(L("eof"));
+	closehtml();
+}
+
+void
+out(Rune *s)
+{
+	if(s == nil)
+		return;
+	for(; *s; s++)
+		outrune(*s);
+}
+
+void (*outcb)(Rune);
+
+void
+inroman(Rune r)
+{
+	int f;
+	
+	f = getnr(L(".f"));
+	nr(L(".f"), 1);
+	runmacro1(L("font"));
+	outrune(r);
+	nr(L(".f"), f);
+	runmacro1(L("font"));
+}
+
+void
+Brune(Rune r)
+{
+	if(r == '&')
+		Bprint(&bout, "&amp;");
+	else if(r == '<')
+		Bprint(&bout, "&lt;");
+	else if(r == '>')
+		Bprint(&bout, "&gt;");
+	else if(r < Runeself || utf8)
+		Bprint(&bout, "%C", r);
+	else
+		Bprint(&bout, "%S", rune2html(r));
+}
+
+void
+outhtml(Rune *s)
+{
+	Rune r;
+	
+	for(; *s; s++){
+		switch(r = *s){
+		case '<':
+			r = Ult;
+			break;
+		case '>':
+			r = Ugt;
+			break;
+		case '&':
+			r = Uamp;
+			break;
+		case ' ':
+			r = Uspace;
+			break;
+		}
+		outrune(r);
+	}
+}
+
+void
+outrune(Rune r)
+{
+	switch(r){
+	case ' ':
+		if(getnr(L(".fi")) == 0)
+			r = Unbsp;
+		break;
+	case Uformatted:
+	case Uunformatted:
+		abort();
+	}
+	if(outcb){
+		if(r == ' ')
+			r = Uspace;
+		outcb(r);
+		return;
+	}
+	/* writing to bout */
+	switch(r){
+	case Uempty:
+		return;
+	case Upl:
+		inroman('+');
+		return;
+	case Ueq:
+		inroman('=');
+		return;
+	case Umi:
+		inroman(0x2212);
+		return;
+	case Utick:
+		r = '\'';
+		break;
+	case Ubtick:
+		r = '`';
+		break;
+	case Uminus:
+		r = '-';
+		break;
+	case '\'':
+		Bprint(&bout, "&rsquo;");
+		return;
+	case '`':
+		Bprint(&bout, "&lsquo;");
+		return;
+	case Uamp:
+		Bputrune(&bout, '&');
+		return;
+	case Ult:
+		Bputrune(&bout, '<');
+		return;
+	case Ugt:
+		Bputrune(&bout, '>');
+		return;
+	case Uspace:
+		Bputrune(&bout, ' ');
+		return;
+	case 0x2032:
+		/*
+		 * In Firefox, at least, the prime is not
+		 * a superscript by default.
+		 */
+		Bprint(&bout, "<sup>");
+		Brune(r);
+		Bprint(&bout, "</sup>");
+		return;
+	}
+	Brune(r);
+}
+
+void
+r_nop(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+}
+
+void
+r_warn(int argc, Rune **argv)
+{
+	USED(argc);
+	warn("ignoring %C%S", dot, argv[0]);
+}
+
+int
+e_warn(void)
+{
+	/* dispatch loop prints a warning for us */
+	return 0;
+}
+
+int
+e_nop(void)
+{
+	return 0;
+}

+ 186 - 0
sys/src/cmd/htmlroff/t1.c

@@ -0,0 +1,186 @@
+#include "a.h"
+ 
+/*
+ * Section 1 - General Explanation.
+ */
+
+/* 1.3 - Numerical parameter input.  */
+char *units = "icPmnpuvx";
+int
+scale2units(char c)
+{
+	int x;
+	
+	switch(c){
+	case 'i':	/* inch */
+		return UPI;
+	case 'c':	/* centimeter */
+		return 0.3937008 * UPI;
+	case 'P':	/* pica = 1/6 inch */
+		return UPI / 6;
+	case 'm':	/* em = S points */
+		return UPI / 72.0 * getnr(L(".s"));
+	case 'n':	/* en = em/2 */
+		return UPI / 72.0 * getnr(L(".s")) / 2;
+	case 'p':	/* point = 1/72 inch */
+		return UPI / 72;
+	case 'u':	/* basic unit */
+		return 1;
+	case 'v':	/* vertical line space V */
+		x = getnr(L(".v"));
+		if(x == 0)
+			x = 12 * UPI / 72;
+		return x;
+	case 'x':	/* pixel (htmlroff addition) */
+		return UPX;
+	default:
+		return 1;
+	}
+}
+
+/* 1.4 - Numerical expressions. */
+int eval0(Rune**, int, int);
+int
+eval(Rune *s)
+{
+	return eval0(&s, 1, 1);
+}
+long
+runestrtol(Rune *a, Rune **p)
+{
+	long n;
+	
+	n = 0;
+	while('0' <= *a && *a <= '9'){
+		n = n*10 + *a-'0';
+		a++;
+	}
+	*p = a;
+	return n;
+}
+
+int
+evalscale(Rune *s, int c)
+{
+	return eval0(&s, scale2units(c), 1);
+}
+
+int
+eval0(Rune **pline, int scale, int recur)
+{
+	Rune *p;
+	int neg;
+	double f, p10;
+	int x, y;
+
+	neg = 0;
+	p = *pline;
+	while(*p == '-'){
+		neg = 1 - neg;
+		p++;
+	}
+	if(*p == '('){
+		p++;
+		x = eval0(&p, scale, 1);
+		if (*p != ')'){
+			*pline = p;
+			return x;
+		}
+		p++;
+	}else{
+		f = runestrtol(p, &p);
+		if(*p == '.'){
+			p10 = 1.0;
+			p++;
+			while('0' <= *p && *p <= '9'){
+				p10 /= 10;
+				f += p10*(*p++ - '0');
+			}
+		}
+		if(*p && strchr(units, *p)){
+			if(scale)
+				f *= scale2units(*p);
+			p++;
+		}else if(scale)
+			f *= scale;
+		x = f;
+	}
+	if(neg)
+		x = -x;
+	if(!recur){
+		*pline = p;
+		return x;
+	}
+	
+	while(*p){
+		switch(*p++) {
+		case '+':
+			x += eval0(&p, scale, 0);
+			continue;
+		case '-':
+			x -= eval0(&p, scale, 0);
+			continue;
+		case '*':
+			x *= eval0(&p, scale, 0);
+			continue;
+		case '/':
+			y = eval0(&p, scale, 0);
+			if (y == 0) {
+				fprint(2, "%L: divide by zero %S\n", p);
+				y = 1;
+			}
+			x /= y;
+			continue;
+		case '%':
+			y = eval0(&p, scale, 0);
+			if (!y) {
+				fprint(2, "%L: modulo by zero %S\n", p);
+				y = 1;
+			}
+			x %= y;
+			continue;
+		case '<':
+			if (*p == '=') {
+				p++;
+				x = x <= eval0(&p, scale, 0);
+				continue;
+			}
+			x = x < eval0(&p, scale, 0);
+			continue;
+		case '>':
+			if (*p == '=') {
+				p++;
+				x = x >= eval0(&p, scale, 0);
+				continue;
+			}
+			x = x > eval0(&p, scale, 0);
+			continue;
+		case '=':
+			if (*p == '=')
+				p++;
+			x = x == eval0(&p, scale, 0);
+			continue;
+		case '&':
+			x &= eval0(&p, scale, 0);
+			continue;
+		case ':':
+			x |= eval0(&p, scale, 0);
+			continue;
+		}
+	}
+	*pline = p;
+	return x;
+}
+
+void
+t1init(void)
+{
+	Tm tm;
+	
+	tm = *localtime(time(0));
+	nr(L("dw"), tm.wday+1);
+	nr(L("dy"), tm.mday);
+	nr(L("mo"), tm.mon);
+	nr(L("yr"), tm.year%100);
+}
+

+ 140 - 0
sys/src/cmd/htmlroff/t10.c

@@ -0,0 +1,140 @@
+#include "a.h"
+
+/*
+ * 10. Input and Output Conventions and Character Translation.
+ */
+
+/* set escape character */
+void
+r_ec(int argc, Rune **argv)
+{
+	if(argc == 1)
+		backslash = '\\';
+	else
+		backslash = argv[1][0];
+}
+
+/* turn off escape character */
+void
+r_eo(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	backslash = -2;
+}
+
+/* continuous underline (same as ul in troff) for the next N lines */
+/* set underline font */
+void
+g_uf(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+}
+
+/* set control character */
+void
+r_cc(int argc, Rune **argv)
+{
+	if(argc == 1)
+		dot = '.';
+	else
+		dot = argv[1][0];
+}
+
+/* set no-break control character */
+void
+r_c2(int argc, Rune **argv)
+{
+	if(argc == 1)
+		tick = '\'';
+	else
+		tick = argv[1][0];
+}
+
+/* output translation */
+
+int
+e_bang(void)
+{
+	Rune *line;
+	
+	line = readline(CopyMode);
+	out(line);
+	outrune('\n');
+	free(line);
+	return 0;
+}
+
+int
+e_X(void)
+{
+	int c;
+	
+	while((c = getrune()) >= 0 && c != '\'' && c != '\n')
+		outrune(c);
+	if(c == '\n'){
+		warn("newline in %CX'...'", backslash);
+		outrune(c);
+	}
+	if(c < 0)
+		warn("eof in %CX'...'", backslash);
+	return 0;
+}
+
+int
+e_quote(void)
+{
+	int c;
+
+	if(inputmode&ArgMode){
+		/* Leave \" around for argument parsing */
+		ungetrune('"');
+		return '\\';
+	}
+	while((c = getrune()) >= 0 && c != '\n')
+		;
+	return '\n';
+}
+
+int
+e_newline(void)
+{
+	return 0;
+}
+
+int
+e_e(void)
+{
+	return backslash;
+}
+
+void
+r_comment(Rune *name)
+{
+	int c;
+	
+	USED(name);
+	while((c = getrune()) >= 0 && c != '\n')
+		;
+}
+
+void
+t10init(void)
+{
+	addreq(L("ec"), r_ec, -1);
+	addreq(L("eo"), r_eo, 0);
+	addreq(L("lg"), r_nop, -1);
+	addreq(L("cc"), r_cc, -1);
+	addreq(L("c2"), r_c2, -1);
+	addreq(L("tr"), r_warn, -1);
+	addreq(L("ul"), r_nop, -1);
+	addraw(L("\\\""), r_comment);
+	
+	addesc('!', e_bang, 0);
+	addesc('X', e_X, 0);
+	addesc('\"', e_quote, CopyMode|ArgMode);
+	addesc('\n', e_newline, CopyMode|ArgMode|HtmlMode);
+	addesc('e', e_e, 0);
+}
+

+ 107 - 0
sys/src/cmd/htmlroff/t11.c

@@ -0,0 +1,107 @@
+#include "a.h"
+
+/*
+ * 11. Local Horizontal and Vertical Motions, and the Width Function.
+ */
+
+int
+e_0(void)
+{
+	/* digit-width space */
+	return ' ';
+}
+
+int
+dv(int d)
+{
+	Rune sub[6];
+
+	d += getnr(L(".dv"));
+	nr(L(".dv"), d);
+
+	runestrcpy(sub, L("<sub>"));
+	sub[0] = Ult;
+	sub[4] = Ugt;
+	if(d < 0){
+		sub[3] = 'p';
+		ihtml(L(".dv"), sub);
+	}else if(d > 0)
+		ihtml(L(".dv"), sub);
+	else
+		ihtml(L(".dv"), nil);
+	return 0;
+}
+
+int
+e_v(void)
+{
+	dv(eval(getqarg()));
+	return 0;
+}
+
+int
+e_u(void)
+{
+	dv(eval(L("-0.5m")));
+	return 0;
+}
+
+int
+e_d(void)
+{
+	dv(eval(L("0.5m")));
+	return 0;
+}
+
+int
+e_r(void)
+{
+	dv(eval(L("-1m")));
+	return 0;
+}
+
+int
+e_h(void)
+{
+	getqarg();
+	return 0;
+}
+
+int
+e_w(void)
+{
+	Rune *a;
+	Rune buf[40];
+	
+	a = getqarg();
+	runesnprint(buf, sizeof buf, "%ld", runestrlen(a));
+	pushinputstring(buf);
+	nr(L("st"), 0);
+	nr(L("sb"), 0);
+	nr(L("ct"), 0);
+	return 0;
+}
+
+int
+e_k(void)
+{
+	getname();
+	warn("%Ck not available", backslash);
+	return 0;
+}
+
+void
+t11init(void)
+{
+	addesc('|', e_nop, 0);
+	addesc('^', e_nop, 0);
+	addesc('v', e_v, 0);
+	addesc('h', e_h, 0);
+	addesc('w', e_w, 0);
+	addesc('0', e_0, 0);
+	addesc('u', e_u, 0);
+	addesc('d', e_d, 0);
+	addesc('r', e_r, 0);
+	addesc('k', e_k, 0);
+}
+

+ 67 - 0
sys/src/cmd/htmlroff/t12.c

@@ -0,0 +1,67 @@
+#include "a.h"
+
+/*
+ * 12. Overstrike, bracket, line-drawing, graphics, and zero-width functions.
+ */
+
+/*
+	\o'asdf'
+	\zc
+	\b'asdf'
+	\l'Nc'
+	\L'Nc'
+	\D'xxx'
+*/
+
+int
+e_o(void)
+{
+	pushinputstring(getqarg());
+	return 0;
+}
+
+int
+e_z(void)
+{
+	getnext();
+	return 0;
+}
+
+int
+e_b(void)
+{
+	pushinputstring(getqarg());
+	return 0;
+}
+
+int
+e_l(void)
+{
+	getqarg();
+	return 0;
+}
+
+int
+e_L(void)
+{
+	getqarg();
+	return 0;
+}
+
+int
+e_D(void)
+{
+	getqarg();
+	return 0;
+}
+
+void
+t12init(void)
+{
+	addesc('o', e_o, 0);
+	addesc('z', e_z, 0);
+	addesc('b', e_b, 0);
+	addesc('l', e_l, 0);
+	addesc('L', e_L, 0);
+	addesc('D', e_D, 0);
+}

+ 17 - 0
sys/src/cmd/htmlroff/t13.c

@@ -0,0 +1,17 @@
+#include "a.h"
+
+/*
+ * 13. Hyphenation.
+ */
+
+void
+t13init(void)
+{
+	addreq(L("nh"), r_nop, -1);
+	addreq(L("hy"), r_nop, -1);
+	addreq(L("hc"), r_nop, -1);
+	addreq(L("hw"), r_nop, -1);
+	
+	addesc('%', e_nop, 0);
+}
+

+ 33 - 0
sys/src/cmd/htmlroff/t14.c

@@ -0,0 +1,33 @@
+#include "a.h"
+
+/*
+ * 14. Three-part titles.
+ */
+void
+r_lt(int argc, Rune **argv)
+{
+	Rune *p;
+	
+	if(argc < 2)
+		nr(L(".lt"), evalscale(L("6.5i"), 'm'));
+	else{
+		if(argc > 2)
+			warn("too many arguments for .lt");
+		p = argv[1];
+		if(p[0] == '-')
+			nr(L(".lt"), getnr(L(".lt"))-evalscale(p+1, 'm'));
+		else if(p[0] == '+')
+			nr(L(".lt"), getnr(L(".lt"))+evalscale(p+1, 'm'));
+		else
+			nr(L(".lt"), evalscale(p, 'm'));
+	}
+}
+
+void
+t14init(void)
+{
+	addreq(L("tl"), r_warn, -1);
+	addreq(L("pc"), r_nop, -1);	/* page number char */
+	addreq(L("lt"), r_lt, -1);
+}
+

+ 13 - 0
sys/src/cmd/htmlroff/t15.c

@@ -0,0 +1,13 @@
+#include "a.h"
+
+/*
+ * 15. Output line numbering.
+ */
+
+void
+t15init(void)
+{
+	addreq(L("nm"), r_warn, -1);
+	addreq(L("nn"), r_warn, -1);
+}
+

+ 156 - 0
sys/src/cmd/htmlroff/t16.c

@@ -0,0 +1,156 @@
+#include "a.h"
+
+/*
+ * 16. Conditional acceptance of input.
+ *
+ *	conditions are
+ *		c - condition letter (o, e, t, n)
+ *		!c - not c
+ *		N - N>0
+ *		!N - N <= 0
+ *		'a'b' - if a==b
+ *		!'a'b'	- if a!=b
+ *
+ *	\{xxx\} can be used for newline in bodies
+ *
+ *	.if .ie .el
+ *
+ */
+
+int iftrue[20];
+int niftrue;
+
+void
+startbody(void)
+{
+	int c;
+			
+	while((c = getrune()) == ' ' || c == '\t')
+		;
+	ungetrune(c);
+}
+
+void
+skipbody(void)
+{
+	int c, cc, nbrace;
+
+	nbrace = 0;
+	for(cc=0; (c = getrune()) >= 0; cc=c){
+		if(c == '\n' && nbrace <= 0)
+			break;
+		if(cc == '\\' && c == '{')
+			nbrace++;
+		if(cc == '\\' && c == '}')
+			nbrace--;
+	}
+}
+
+int
+ifeval(void)
+{
+	int c, cc, neg, nc;
+	Rune line[MaxLine], *p, *e, *q;
+	Rune *a;
+	
+	while((c = getnext()) == ' ' || c == '\t')
+		;
+	neg = 0;
+	while(c == '!'){
+		neg = !neg;
+		c = getnext();
+	}
+
+	if('0' <= c && c <= '9'){
+		ungetnext(c);
+		a = copyarg();
+		c = (eval(a)>0) ^ neg;
+		free(a);
+		return c;
+	}
+	
+	switch(c){
+	case ' ':
+	case '\n':
+		ungetnext(c);
+		return !neg;
+	case 'o':	/* odd page */
+	case 't':	/* troff */
+	case 'h':	/* htmlroff */
+		while((c = getrune()) != ' ' && c != '\t' && c != '\n' && c >= 0)
+			;
+		return 1 ^ neg;
+	case 'n':	/* nroff */
+	case 'e':	/* even page */
+		while((c = getnext()) != ' ' && c != '\t' && c != '\n' && c >= 0)
+			;
+		return 0 ^ neg;
+	}
+
+	/* string comparison 'string1'string2' */
+	p = line;
+	e = p+nelem(line);
+	nc = 0;
+	q = nil;
+	while((cc=getnext()) >= 0 && cc != '\n' && p<e){
+		if(cc == c){
+			if(++nc == 2)
+				break;
+			q = p;
+		}
+		*p++ = cc;
+	}
+	if(cc != c){
+		ungetnext(cc);
+		return 0;
+	}
+	if(nc < 2){
+		return 0;
+	}
+	*p = 0;
+	return (q-line == p-(q+1)
+		&& memcmp(line, q+1, (q-line)*sizeof(Rune))==0) ^ neg;
+}
+	
+void
+r_if(Rune *name)
+{
+	int n;
+	
+	n = ifeval();
+	if(runestrcmp(name, L("ie")) == 0){
+		if(niftrue >= nelem(iftrue))
+			sysfatal("%Cie overflow", dot);
+		iftrue[niftrue++] = n;
+	}
+	if(n)
+		startbody();
+	else
+		skipbody();
+}
+
+void
+r_el(Rune *name)
+{
+	USED(name);
+	
+	if(niftrue <= 0){
+		warn("%Cel underflow", dot);
+		return;
+	}
+	if(iftrue[--niftrue])
+		skipbody();
+	else
+		startbody();
+}
+
+void
+t16init(void)
+{
+	addraw(L("if"), r_if);
+	addraw(L("ie"), r_if);
+	addraw(L("el"), r_el);
+	
+	addesc('{', e_nop, HtmlMode|ArgMode);
+	addesc('}', e_nop, HtmlMode|ArgMode);
+}

+ 131 - 0
sys/src/cmd/htmlroff/t17.c

@@ -0,0 +1,131 @@
+#include "a.h"
+
+/*
+ * 17.  Environment switching.
+ */
+typedef struct Env Env;
+struct Env
+{
+	int s;
+	int s0;
+	int f;
+	int f0;
+	int fi;
+	int ad;
+	int ce;
+	int v;
+	int v0;
+	int ls;
+	int ls0;
+	int it;
+	/* - ta */
+	/* - tc */
+	/* - lc */
+	/* - ul */
+	/* - cu */
+	/* - cc */
+	/* - c2 */
+	/* - nh */
+	/* - hy */
+	/* - hc */
+	/* - lt */
+	/* - nm */
+	/* - nn */
+	/* - mc */
+};
+
+Env defenv =
+{
+	10,
+	10,
+	1,
+	1,
+	1,
+	1,
+	0,
+	12,
+	12,
+	0,
+	0,
+	0,
+};
+
+Env env[3];
+Env *evstack[20];
+int nevstack;
+
+void
+saveenv(Env *e)
+{
+	e->s = getnr(L(".s"));
+	e->s0 = getnr(L(".s0"));
+	e->f = getnr(L(".f"));
+	e->f0 = getnr(L(".f0"));
+	e->fi = getnr(L(".fi"));
+	e->ad = getnr(L(".ad"));
+	e->ce = getnr(L(".ce"));
+	e->v = getnr(L(".v"));
+	e->v0 = getnr(L(".v0"));
+	e->ls = getnr(L(".ls"));
+	e->ls0 = getnr(L(".ls0"));
+	e->it = getnr(L(".it"));
+}
+
+void
+restoreenv(Env *e)
+{
+	nr(L(".s"), e->s);
+	nr(L(".s0"), e->s0);
+	nr(L(".f"), e->f);
+	nr(L(".f0"), e->f0);
+	nr(L(".fi"), e->fi);
+	nr(L(".ad"), e->ad);
+	nr(L(".ce"), e->ce);
+	nr(L(".v"), e->v);
+	nr(L(".v0"), e->v0);
+	nr(L(".ls"), e->ls);
+	nr(L(".ls0"), e->ls0);
+	nr(L(".it"), e->it);
+
+	nr(L(".ev"), e-env);
+	runmacro1(L("font"));
+}
+
+
+void
+r_ev(int argc, Rune **argv)
+{
+	int i;
+	Env *e;
+	
+	if(argc == 1){
+		if(nevstack <= 0){
+			if(verbose) warn(".ev stack underflow");
+			return;
+		}
+		restoreenv(evstack[--nevstack]);
+		return;
+	}
+	if(nevstack >= nelem(evstack))
+		sysfatal(".ev stack overflow");
+	i = eval(argv[1]);
+	if(i < 0 || i > 2){
+		warn(".ev bad environment %d", i);
+		i = 0;
+	}
+	e = &env[getnr(L(".ev"))];
+	saveenv(e);
+	evstack[nevstack++] = e;
+	restoreenv(&env[i]);
+}
+
+void
+t17init(void)
+{
+	int i;
+	
+	for(i=0; i<nelem(env); i++)
+		env[i] = defenv;
+
+	addreq(L("ev"), r_ev, -1);
+}

+ 68 - 0
sys/src/cmd/htmlroff/t18.c

@@ -0,0 +1,68 @@
+#include "a.h"
+
+/*
+ * 18. Insertions from the standard input
+ */
+void
+r_rd(int argc, Rune **argv)
+{
+	char buf[100];
+	char *s;
+	Rune *p;
+	Fmt fmt;
+	static int didstdin;
+	static Biobuf bstdin;
+	
+	/*
+	 * print prompt, then read until double newline,
+	 * then run the text just read as though it were
+	 * a macro body, using the remaining arguments.
+	 */
+	if(fd2path(0, buf, sizeof buf) >= 0 && strstr(buf, "/dev/cons")){
+		if(argc > 1)
+			fprint(2, "%S", argv[1]);
+		else
+			fprint(2, "%c", 7/*BEL*/);
+	}
+	
+	if(!didstdin){
+		Binit(&bstdin, 0, OREAD);
+		didstdin = 1;
+	}
+	runefmtstrinit(&fmt);
+	while((s = Brdstr(&bstdin, '\n', 0)) != nil){
+		if(s[0] == '\n'){
+			free(s);
+			break;
+		}
+		fmtprint(&fmt, "%s", s);
+		free(s);
+	}
+	p = runefmtstrflush(&fmt);
+	if(p == nil)
+		warn("out of memory in %Crd", dot);
+	ds(L(".rd"), p);
+	argc--;
+	argv++;
+	argv[0] = L(".rd");
+	runmacro('.', argc, argv);
+	ds(L(".rd"), nil);
+}
+
+/* terminate exactly as if input had ended */
+void
+r_ex(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	
+	while(popinput())
+		;
+}
+
+void
+t18init(void)
+{
+	addreq(L("rd"), r_rd, -1);
+	addreq(L("ex"), r_ex, 0);
+}

+ 142 - 0
sys/src/cmd/htmlroff/t19.c

@@ -0,0 +1,142 @@
+#include "a.h"
+
+/*
+ * 19. Input/output file switching.
+ */
+
+/* .so - push new source file */
+void
+r_so(int argc, Rune **argv)
+{
+	USED(argc);
+	pushinputfile(argv[1]);
+}
+
+/* .nx - end this file, switch to arg */
+void
+r_nx(int argc, Rune **argv)
+{
+	int n;
+	
+	if(argc == 1){
+		while(popinput())
+			;
+	}else{
+		if(argc > 2)
+			warn("too many arguments for .nx");
+		while((n=popinput()) && n != 2)
+			;
+		pushinputfile(argv[1]);
+	}
+}
+
+/* .sy - system: run string */
+void
+r_sy(Rune *name)
+{
+	USED(name);
+	warn(".sy not implemented");
+}
+
+/* .pi - pipe output to string */
+void
+r_pi(Rune *name)
+{
+	USED(name);
+	warn(".pi not implemented");
+}
+
+/* .cf - copy contents of filename to output */
+void
+r_cf(int argc, Rune **argv)
+{
+	int c;
+	char *p;
+	Biobuf *b;
+
+	USED(argc);
+	p = esmprint("%S", argv[1]);
+	if((b = Bopen(p, OREAD)) == nil){
+		fprint(2, "%L: open %s: %r\n", p);
+		free(p);
+		return;
+	}
+	free(p);
+
+	while((c = Bgetrune(b)) >= 0)
+		outrune(c);
+	Bterm(b);
+}
+
+void
+r_inputpipe(Rune *name)
+{
+	Rune *cmd, *stop, *line;
+	int n, pid, p[2], len;
+	Waitmsg *w;
+	
+	USED(name);
+	if(pipe(p) < 0){
+		warn("pipe: %r");
+		return;
+	}
+	stop = copyarg();
+	cmd = readline(CopyMode);
+	pid = fork();
+	switch(pid){
+	case 0:
+		if(p[0] != 0){
+			dup(p[0], 0);
+			close(p[0]);
+		}
+		close(p[1]);
+		execl("/bin/rc", "rc", "-c", esmprint("%S", cmd), nil);
+		warn("%Cdp %S: %r", dot, cmd);
+		_exits(nil);
+	case -1:
+		warn("fork: %r");
+	default:
+		close(p[0]);
+		len = runestrlen(stop);
+		fprint(p[1], ".ps %d\n", getnr(L(".s")));
+		fprint(p[1], ".vs %du\n", getnr(L(".v")));
+		fprint(p[1], ".ft %d\n", getnr(L(".f")));
+		fprint(p[1], ".ll 8i\n");
+		fprint(p[1], ".pl 30i\n");
+		while((line = readline(~0)) != nil){
+			if(runestrncmp(line, stop, len) == 0 
+			&& (line[len]==' ' || line[len]==0 || line[len]=='\t'
+				|| (line[len]=='\\' && line[len+1]=='}')))
+				break;
+			n = runestrlen(line);
+			line[n] = '\n';
+			fprint(p[1], "%.*S", n+1, line);
+			free(line);
+		}
+		free(stop);
+		close(p[1]);
+		w = wait();
+		if(w == nil){
+			warn("wait: %r");
+			return;
+		}
+		if(w->msg[0])
+			sysfatal("%C%S %S: %s", dot, name, cmd, w->msg);
+		free(cmd);
+		free(w);
+	}
+}	
+
+void
+t19init(void)
+{
+	addreq(L("so"), r_so, 1);
+	addreq(L("nx"), r_nx, -1);
+	addraw(L("sy"), r_sy);
+	addraw(L("inputpipe"), r_inputpipe);
+	addraw(L("pi"), r_pi);
+	addreq(L("cf"), r_cf, 1);
+	
+	nr(L("$$"), getpid());
+}
+

+ 274 - 0
sys/src/cmd/htmlroff/t2.c

@@ -0,0 +1,274 @@
+#include "a.h"
+
+/*
+ * Section 2 - Font and character size control.
+ */
+ 
+/* 2.1 - Character set */
+/* XXX
+ *
+ * \C'name' - character named name
+ * \N'n' - character number
+ * \(xx - two-letter character
+ * \- 
+ * \`
+ * \'
+ * `
+ * '
+ * -
+ */
+
+Rune*
+getqarg(void)
+{
+	static Rune buf[MaxLine];
+	int c;
+	Rune *p, *e;
+	
+	p = buf;
+	e = p+sizeof buf-1;
+	
+	if(getrune() != '\'')
+		return nil;
+	while(p < e){
+		c = getrune();
+		if(c < 0)
+			return nil;
+		if(c == '\'')
+			break;
+		*p++ = c;
+	}
+	*p = 0;
+	return buf;
+}
+
+int
+e_N(void)
+{
+	Rune *a;
+	if((a = getqarg()) == nil)
+		goto error;
+	return eval(a);
+
+error:
+	warn("malformed %CN'...'", backslash);
+	return 0;
+}
+
+int
+e_paren(void)
+{
+	int c, cc;
+	Rune buf[2], r;
+	
+	if((c = getrune()) < 0 || c == '\n')
+		goto error;
+	if((cc = getrune()) < 0 || cc == '\n')
+		goto error;
+	buf[0] = c;
+	buf[1] = cc;
+	r = troff2rune(buf);
+ 	if(r == Runeerror)
+		warn("unknown char %C(%C%C", backslash, c, cc);
+	return r;
+	
+error:
+	warn("malformed %C(xx", backslash);
+	return 0;
+}
+
+/* 2.2 - Fonts */
+Rune fonttab[10][100];
+
+/*
+ * \fx \f(xx \fN - font change
+ * number register .f - current font
+ * \f0 previous font (undocumented?)
+ */
+/* change to font f.  also \fx, \f(xx, \fN */
+/* .ft LongName is okay - temporarily at fp 0 */
+void
+ft(Rune *f)
+{
+	int i;
+	int fn;
+	
+	if(f && runestrcmp(f, L("P")) == 0)
+		f = nil;
+	if(f == nil)
+		fn = 0;
+	else if(isdigit(f[0]))
+		fn = eval(f);
+	else{
+		for(i=0; i<nelem(fonttab); i++){
+			if(runestrcmp(fonttab[i], f) == 0){
+				fn = i;
+				goto have;
+			}
+		}
+		warn("unknown font %S", f);
+		fn = 1;
+	}
+have:
+	if(fn < 0 || fn >= nelem(fonttab)){
+		warn("unknown font %d", fn);
+		fn = 1;
+	}
+	if(fn == 0)
+		fn = getnr(L(".f0"));
+	nr(L(".f0"), getnr(L(".f")));
+	nr(L(".f"), fn);
+	runmacro1(L("font"));
+}
+
+/* mount font named f on physical position N */
+void
+fp(int i, Rune *f)
+{
+	if(i <= 0 || i >= nelem(fonttab)){
+		warn("bad font position %d", i);
+		return;
+	}
+	runestrecpy(fonttab[i], fonttab[i]+sizeof fonttab[i], f);
+}
+	
+int
+e_f(void)
+{
+	ft(getname());
+	return 0;
+}
+
+void
+r_ft(int argc, Rune **argv)
+{
+	if(argc == 1)
+		ft(nil);
+	else
+		ft(argv[1]);
+}
+
+void
+r_fp(int argc, Rune **argv)
+{
+	if(argc < 3){
+		warn("missing arguments to %Cfp", dot);
+		return;
+	}
+	fp(eval(argv[1]), argv[2]);
+}
+
+/* 2.3 - Character size */
+
+/* \H'±N' sets height */
+
+void
+ps(int s)
+{
+	if(s == 0)
+		s = getnr(L(".s0"));
+	nr(L(".s0"), getnr(L(".s")));
+	nr(L(".s"), s);
+	runmacro1(L("font"));
+}
+
+/* set point size */
+void
+r_ps(int argc, Rune **argv)
+{
+	Rune *p;
+	
+	if(argc == 1 || argv[1][0] == 0)
+		ps(0);
+	else{
+		p = argv[1];
+		if(p[0] == '-')
+			ps(getnr(L(".s"))-eval(p+1));
+		else if(p[0] == '+')
+			ps(getnr(L(".s"))+eval(p+1));
+		else
+			ps(eval(p));
+	}
+}
+
+int
+e_s(void)
+{
+	int c, cc, ccc, n, twodigit;
+	
+	c = getnext();
+	if(c < 0)
+		return 0;
+	if(c == '+' || c == '-'){
+		cc = getnext();
+		if(cc == '('){
+			cc = getnext();
+			ccc = getnext();
+			if(cc < '0' || cc > '9' || ccc < '0' || ccc > '9'){
+				warn("bad size %Cs%C(%C%C", backslash, c, cc, ccc);
+				return 0;
+			}
+			n = (cc-'0')*10+ccc-'0';
+		}else{
+			if(cc < '0' || cc > '9'){
+				warn("bad size %Cs%C%C", backslash, c, cc);
+				return 0;
+			}
+			n = cc-'0';
+		}
+		if(c == '+')
+			ps(getnr(L(".s"))+n);
+		else
+			ps(getnr(L(".s"))-n);
+		return 0;
+	}
+	twodigit = 0;
+	if(c == '('){
+		twodigit = 1;
+		c = getnext();
+		if(c < 0)
+			return 0;
+	}
+	if(c < '0' || c > '9'){
+		warn("bad size %Cs%C", backslash, c);
+		ungetnext(c);
+		return 0;
+	}
+	if(twodigit || (c < '4' && c != '0')){
+		cc = getnext();
+		if(c < 0)
+			return 0;
+		n = (c-'0')*10+cc-'0';
+	}else
+		n = c-'0';
+	ps(n);
+	return 0;
+}
+
+void
+t2init(void)
+{
+	fp(1, L("R"));
+	fp(2, L("I"));
+	fp(3, L("B"));
+	fp(4, L("BI"));
+	fp(5, L("CW"));
+	
+	nr(L(".s"), 10);
+	nr(L(".s0"), 10);
+
+	addreq(L("ft"), r_ft, -1);
+	addreq(L("fp"), r_fp, -1);
+	addreq(L("ps"), r_ps, -1);
+	addreq(L("ss"), r_warn, -1);
+	addreq(L("cs"), r_warn, -1);
+	addreq(L("bd"), r_warn, -1);
+
+	addesc('f', e_f, 0);
+	addesc('s', e_s, 0);
+	addesc('(', e_paren, 0);	/* ) */
+	addesc('C', e_warn, 0);
+	addesc('N', e_N, 0);
+	/* \- \' \` are handled in html.c */
+}
+

+ 79 - 0
sys/src/cmd/htmlroff/t20.c

@@ -0,0 +1,79 @@
+#include "a.h"
+
+/*
+ * 20. Miscellaneous
+ */
+
+/* .mc - margin character */
+/* .ig - ignore; treated like a macro in t7.c */
+
+/* .pm - print macros and strings */
+
+void
+r_pm(int argc, Rune **argv)
+{
+	int i;
+	
+	if(argc == 1){
+		printds(0);
+		return;
+	}
+	if(runestrcmp(argv[1], L("t")) == 0){
+		printds(1);
+		return;
+	}
+	for(i=1; i<argc; i++)
+		fprint(2, "%S: %S\n", argv[i], getds(argv[i]));
+}
+
+void
+r_tm(Rune *name)
+{
+	Rune *line;
+	
+	USED(name);
+	
+	line = readline(CopyMode);
+	fprint(2, "%S\n", line);
+	free(line);
+}
+
+void
+r_ab(Rune *name)
+{
+	USED(name);
+	
+	r_tm(L("ab"));
+	exits(".ab");
+}
+
+void
+r_lf(int argc, Rune **argv)
+{
+	if(argc == 1)
+		return;
+	if(argc == 2)
+		setlinenumber(nil, eval(argv[1]));
+	if(argc == 3)
+		setlinenumber(argv[2], eval(argv[1]));
+}
+
+void
+r_fl(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	Bflush(&bout);
+}
+
+void
+t20init(void)
+{
+	addreq(L("mc"), r_warn, -1);
+	addraw(L("tm"), r_tm);
+	addraw(L("ab"), r_ab);
+	addreq(L("lf"), r_lf, -1);
+	addreq(L("pm"), r_pm, -1);
+	addreq(L("fl"), r_fl, 0);
+}
+

+ 49 - 0
sys/src/cmd/htmlroff/t3.c

@@ -0,0 +1,49 @@
+#include "a.h"
+
+/*
+ * Section 3 - page control (mostly irrelevant).
+ */
+
+/* page offset */
+void
+po(int o)
+{
+	nr(L(".o0"), getnr(L(".o")));
+	nr(L(".o"), o);
+}
+
+void
+r_po(int argc, Rune **argv)
+{
+	if(argc == 1){
+		po(getnr(L(".o0")));
+		return;
+	}
+	if(argv[1][0] == '+')
+		po(getnr(L(".o"))+evalscale(argv[1]+1, 'v'));
+	else if(argv[1][0] == '-')
+		po(getnr(L(".o"))-evalscale(argv[1]+1, 'v'));
+	else
+		po(evalscale(argv[1], 'v'));
+}
+
+/* .ne - need vertical space */
+/* .mk - mark current vertical place */
+/* .rt - return upward */
+
+void
+t3init(void)
+{
+	nr(L(".o"), eval(L("1i")));
+	nr(L(".o0"), eval(L("1i")));
+	nr(L(".p"), eval(L("11i")));
+	
+	addreq(L("pl"), r_warn, -1);
+	addreq(L("bp"), r_nop, -1);
+	addreq(L("pn"), r_warn, -1);
+	addreq(L("po"), r_po, -1);
+	addreq(L("ne"), r_nop, -1);
+	addreq(L("mk"), r_nop, -1);
+	addreq(L("rt"), r_warn, -1);
+}
+

+ 142 - 0
sys/src/cmd/htmlroff/t4.c

@@ -0,0 +1,142 @@
+#include "a.h"
+
+/*
+ * 4 - Text filling, centering, and adjusting.  
+ * 	"\ " - unbreakable space
+ * 	.n register - length of last line
+ *	nl register - text baseline position on this page
+ *	.h register - baseline high water mark
+ *	.k register - current horizontal output position
+ *	\p - cause break at end of word, justify
+ *	\& - non-printing zero-width filler
+ *	tr - output translation
+ *	\c - break (but don't) input line in .nf mode
+ *	\c - break (but don't) word in .fi mode
+ */
+
+int
+e_space(void)
+{
+	return 0xA0;	/* non-breaking space */
+}
+
+int
+e_amp(void)
+{
+	return Uempty;
+}
+
+int
+e_c(void)
+{
+	getrune();
+	bol = 1;
+	return 0;
+}
+
+void
+r_br(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	br();
+}
+
+/* fill mode on */
+void
+r_fi(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	nr(L(".fi"), 1);
+// warn(".fi");
+}
+
+/* no-fill mode */
+void
+r_nf(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	nr(L(".fi"), 0);
+}
+
+/* adjust */
+void
+r_ad(int argc, Rune **argv)
+{
+	int c, n;
+	
+	nr(L(".j"), getnr(L(".j"))|1);
+	if(argc < 2)
+		return;
+	c = argv[1][0];
+	switch(c){
+	default:
+		fprint(2, "%L: bad adjust %C\n", c);
+		return;
+	case 'r':
+		n = 2*2|1;
+		break;
+	case 'l':
+		n = 0;
+		break;
+	case 'c':
+		n = 1*2|1;
+		break;
+	case 'b':
+	case 'n':
+		n = 0*2|1;
+		break;
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+		n = c-'0';
+		break;
+	}
+	nr(L(".j"), n);
+}
+
+/* no adjust */
+void
+r_na(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+
+	nr(L(".j"), getnr(L(".j"))&~1);
+}
+
+/* center next N lines */
+void
+r_ce(int argc, Rune **argv)
+{
+	if(argc < 2)
+		nr(L(".ce"), 1);
+	else
+		nr(L(".ce"), eval(argv[1]));
+	/* XXX set trap */
+}
+
+void
+t4init(void)
+{
+	nr(L(".fi"), 1);
+	nr(L(".j"), 1);
+
+	addreq(L("br"), r_br, 0);
+	addreq(L("fi"), r_fi, 0);
+	addreq(L("nf"), r_nf, 0);
+	addreq(L("ad"), r_ad, -1);
+	addreq(L("na"), r_na, 0);
+	addreq(L("ce"), r_ce, -1);
+	
+	addesc(' ', e_space, 0);
+	addesc('p', e_warn, 0);
+	addesc('&', e_amp, 0);
+	addesc('c', e_c, 0);
+}
+

+ 110 - 0
sys/src/cmd/htmlroff/t5.c

@@ -0,0 +1,110 @@
+#include "a.h"
+
+/*
+ * 5.  Vertical spacing.
+ */
+
+/* set vertical baseline spacing */
+void
+vs(int v)
+{
+	if(v == 0)
+		v = getnr(L(".v0"));
+	nr(L(".v0"), getnr(L(".v")));
+	nr(L(".v"), v);
+}
+
+void
+r_vs(int argc, Rune **argv)
+{
+	if(argc < 2)
+		vs(eval(L("12p")));
+	else if(argv[1][0] == '+')
+		vs(getnr(L(".v"))+evalscale(argv[1]+1, 'p'));
+	else if(argv[1][0] == '-')
+		vs(getnr(L(".v"))-evalscale(argv[1]+1, 'p'));
+	else
+		vs(evalscale(argv[1], 'p'));
+}
+
+/* set line spacing */
+void
+ls(int v)
+{
+	if(v == 0)
+		v = getnr(L(".ls0"));
+	nr(L(".ls0"), getnr(L(".ls")));
+	nr(L(".ls"), v);
+}
+void
+r_ls(int argc, Rune **argv)
+{
+	ls(argc < 2 ? 0 : eval(argv[1]));
+}
+
+/* .sp - space vertically */
+/* .sv - save a contiguous vertical block */
+void
+sp(int v)
+{
+	Rune buf[100];
+	double fv;
+	
+	br();
+	fv = v * 1.0/UPI;
+	if(fv > 5)
+		fv = eval(L("1v")) * 1.0/UPI;
+	runesnprint(buf, nelem(buf), "<p style=\"margin-top: 0; margin-bottom: %.2fin\"></p>\n", fv);
+	outhtml(buf);
+}
+void
+r_sp(int argc, Rune **argv)
+{
+	if(getnr(L(".ns")))
+		return;
+	if(argc < 2)
+		sp(eval(L("1v")));
+	else{
+		if(argv[1][0] == '|'){
+			/* XXX if there's no output yet, do the absolute! */
+			if(verbose)
+				warn("ignoring absolute .sp %d", eval(argv[1]+1));
+			return;
+		}
+		sp(evalscale(argv[1], 'v'));
+	}
+}
+
+void
+r_ns(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	nr(L(".ns"), 1);
+}
+
+void
+r_rs(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	nr(L(".ns"), 0);
+}
+
+void
+t5init(void)
+{	
+	addreq(L("vs"), r_vs, -1);
+	addreq(L("ls"), r_ls, -1);
+	addreq(L("sp"), r_sp, -1);
+	addreq(L("sv"), r_sp, -1);
+	addreq(L("os"), r_nop, -1);
+	addreq(L("ns"), r_ns, 0);
+	addreq(L("rs"), r_rs, 0);
+
+	nr(L(".v"), eval(L("12p")));
+	nr(L(".v0"), eval(L("12p")));
+	nr(L(".ls"), 1);
+	nr(L(".ls0"), 1);
+}
+

+ 74 - 0
sys/src/cmd/htmlroff/t6.c

@@ -0,0 +1,74 @@
+#include "a.h"
+
+/*
+ * Section 6 - line length and indenting.
+ */
+
+/* set line length */
+void
+ll(int v)
+{
+	if(v == 0)
+		v = getnr(L(".l0"));
+	nr(L(".l0"), getnr(L(".l")));
+	nr(L(".l"), v);
+}
+void
+r_ll(int argc, Rune **argv)
+{
+	if(argc < 2)
+		ll(0);
+	else if(argv[1][0] == '+')
+		ll(getnr(L(".l"))+evalscale(argv[1]+1, 'v'));
+	else if(argv[1][0] == '-')
+		ll(getnr(L(".l"))-evalscale(argv[1]+1, 'v'));
+	else
+		ll(evalscale(argv[1], 'm'));
+	if(argc > 2)
+		warn("extra arguments to .ll");
+}
+
+void
+in(int v)
+{
+	nr(L(".i0"), getnr(L(".i")));
+	nr(L(".i"), v);
+	/* XXX */
+}
+void
+r_in(int argc, Rune **argv)
+{
+	if(argc < 2)
+		in(getnr(L(".i0")));
+	else if(argv[1][0] == '+')
+		in(getnr(L(".i"))+evalscale(argv[1]+1, 'm'));
+	else if(argv[1][0] == '-')
+		in(getnr(L(".i"))-evalscale(argv[1]+1, 'm'));
+	else
+		in(evalscale(argv[1], 'm'));
+	if(argc > 3)
+		warn("extra arguments to .in");
+}
+
+void
+ti(int v)
+{
+	nr(L(".ti"), v);
+}
+void
+r_ti(int argc, Rune **argv)
+{
+	USED(argc);
+	ti(evalscale(argv[1], 'm'));
+}
+
+void
+t6init(void)
+{
+	addreq(L("ll"), r_ll, -1);
+	addreq(L("in"), r_in, -1);
+	addreq(L("ti"), r_ti, 1);
+	
+	nr(L(".l"), eval(L("6.5i")));
+}
+

+ 543 - 0
sys/src/cmd/htmlroff/t7.c

@@ -0,0 +1,543 @@
+/*
+ * 7.  Macros, strings, diversion, and position traps.
+ *
+ * 	macros can override builtins
+ *	builtins can be renamed or removed!
+ */
+
+#include "a.h"
+
+enum
+{
+	MAXARG = 10,
+	MAXMSTACK = 40
+};
+
+/* macro invocation frame */
+typedef struct Mac Mac;
+struct Mac
+{
+	int argc;
+	Rune *argv[MAXARG];
+};
+
+Mac		mstack[MAXMSTACK];
+int		nmstack;
+void		emitdi(void);
+void		flushdi(void);
+
+/*
+ * Run a user-defined macro.
+ */
+void popmacro(void);
+int
+runmacro(int dot, int argc, Rune **argv)
+{
+	Rune *p;
+	int i;
+	Mac *m;
+	
+if(verbose && isupperrune(argv[0][0])) fprint(2, "run: %S\n", argv[0]);
+	p = getds(argv[0]);
+	if(p == nil){
+		if(verbose)
+			warn("ignoring unknown request %C%S", dot, argv[0]);
+		if(verbose > 1){
+			for(i=0; i<argc; i++)
+				fprint(2, " %S", argv[i]);
+			fprint(2, "\n");
+		}
+		return -1;
+	}
+	if(nmstack >= nelem(mstack)){
+		fprint(2, "%L: macro stack overflow:");
+		for(i=0; i<nmstack; i++)
+			fprint(2, " %S", mstack[i].argv[0]);
+		fprint(2, "\n");
+		return -1;
+	}
+	m = &mstack[nmstack++];
+	m->argc = argc;
+	for(i=0; i<argc; i++)
+		m->argv[i] = erunestrdup(argv[i]);
+	pushinputstring(p);
+	nr(L(".$"), argc-1);
+	inputnotify(popmacro);
+	return 0;
+}
+
+void
+popmacro(void)
+{
+	int i;
+	Mac *m;
+	
+	if(--nmstack < 0){
+		fprint(2, "%L: macro stack underflow\n");
+		return;
+	}
+	m = &mstack[nmstack];
+	for(i=0; i<m->argc; i++)
+		free(m->argv[i]);
+	if(nmstack > 0)
+		nr(L(".$"), mstack[nmstack-1].argc-1);
+	else
+		nr(L(".$"), 0);
+}
+
+void popmacro1(void);
+jmp_buf runjb[10];
+int nrunjb;
+
+void
+runmacro1(Rune *name)
+{
+	Rune *argv[2];
+	int obol;
+	
+if(verbose) fprint(2, "outcb %p\n", outcb);
+	obol = bol;
+	argv[0] = name;
+	argv[1] = nil;
+	bol = 1;
+	if(runmacro('.', 1, argv) >= 0){
+		inputnotify(popmacro1);
+		if(!setjmp(runjb[nrunjb++]))
+			runinput();
+		else
+			if(verbose) fprint(2, "finished %S\n", name);
+	}
+	bol = obol;
+}
+
+void
+popmacro1(void)
+{
+	popmacro();
+	if(nrunjb >= 0)
+		longjmp(runjb[--nrunjb], 1);
+}
+
+/*
+ * macro arguments
+ *
+ *	"" means " inside " "
+ *	"" empty string
+ *	\newline can be done
+ *	argument separator is space (not tab)
+ *	number register .$ = number of arguments
+ *	no arguments outside macros or in strings
+ *
+ *	arguments copied in copy mode
+ */
+
+/*
+ * diversions
+ *
+ *	processed output diverted 
+ *	dn dl registers vertical and horizontal size of last diversion
+ *	.z - current diversion name
+ */
+
+/*
+ * traps
+ *
+ *	skip most
+ *	.t register - distance to next trap
+ */
+static Rune *trap0;
+
+void
+outtrap(void)
+{
+	Rune *t;
+
+	if(outcb)
+		return;
+	if(trap0){
+if(verbose) fprint(2, "trap: %S\n", trap0);
+		t = trap0;
+		trap0 = nil;
+		runmacro1(t);
+		free(t);
+	}
+}
+
+/* .wh - install trap */
+void
+r_wh(int argc, Rune **argv)
+{
+	int i;
+
+	if(argc < 2)
+		return;
+
+	i = eval(argv[1]);
+	if(argc == 2){
+		if(i == 0){
+			free(trap0);
+			trap0 = nil;
+		}else
+			if(verbose)
+				warn("not removing trap at %d", i);
+	}
+	if(argc > 2){
+		if(i == 0){
+			free(trap0);
+			trap0 = erunestrdup(argv[2]);
+		}else
+			if(verbose)
+				warn("not installing %S trap at %d", argv[2], i);
+	}
+}
+
+void
+r_ch(int argc, Rune **argv)
+{
+	int i;
+	
+	if(argc == 2){
+		if(trap0 && runestrcmp(argv[1], trap0) == 0){
+			free(trap0);
+			trap0 = nil;
+		}else
+			if(verbose)
+				warn("not removing %S trap", argv[1]);
+		return;
+	}
+	if(argc >= 3){
+		i = eval(argv[2]);
+		if(i == 0){
+			free(trap0);
+			trap0 = erunestrdup(argv[1]);
+		}else
+			if(verbose)
+				warn("not moving %S trap to %d", argv[1], i);
+	}
+}
+
+void
+r_dt(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	warn("ignoring diversion trap");
+}
+
+/* define macro - .de, .am, .ig */
+void
+r_de(int argc, Rune **argv)
+{
+	Rune *end, *p;
+	Fmt fmt;
+	int ignore, len;
+
+	delreq(argv[1]);
+	delraw(argv[1]);
+	ignore = runestrcmp(argv[0], L("ig")) == 0;
+	if(!ignore)
+		runefmtstrinit(&fmt);
+	end = L("..");
+	if(argc >= 3)
+		end = argv[2];
+	if(runestrcmp(argv[0], L("am")) == 0 && (p=getds(argv[1])) != nil)
+		fmtrunestrcpy(&fmt, p);
+	len = runestrlen(end);
+	while((p = readline(CopyMode)) != nil){
+		if(runestrncmp(p, end, len) == 0 
+		&& (p[len]==' ' || p[len]==0 || p[len]=='\t'
+			|| (p[len]=='\\' && p[len+1]=='}'))){
+			free(p);
+			goto done;
+		}
+		if(!ignore)
+			fmtprint(&fmt, "%S\n", p);
+		free(p);
+	}
+	warn("eof in %C%S %S - looking for %#Q", dot, argv[0], argv[1], end);
+done:
+	if(ignore)
+		return;
+	p = runefmtstrflush(&fmt);
+	if(p == nil)
+		sysfatal("out of memory");
+	ds(argv[1], p);
+	free(p);
+}
+
+/* define string .ds .as */
+void
+r_ds(Rune *cmd)
+{
+	Rune *name, *line, *p;
+	
+	name = copyarg();
+	line = readline(CopyMode);
+	if(name == nil || line == nil){
+		free(name);
+		return;
+	}
+	p = line;
+	if(*p == '"')
+		p++;
+	if(cmd[0] == 'd')
+		ds(name, p);
+	else
+		as(name, p);
+	free(name);
+	free(line);
+}
+
+/* remove request, macro, or string */
+void
+r_rm(int argc, Rune **argv)
+{
+	int i;
+
+	emitdi();
+	for(i=1; i<argc; i++){
+		delreq(argv[i]);
+		delraw(argv[i]);
+		ds(argv[i], nil);
+	}
+}
+
+/* .rn - rename request, macro, or string */
+void
+r_rn(int argc, Rune **argv)
+{
+	USED(argc);
+	renreq(argv[1], argv[2]);
+	renraw(argv[1], argv[2]);
+	ds(argv[2], getds(argv[1]));
+	ds(argv[1], nil);
+}
+
+/* .di - divert output to macro xx */
+/* .da - divert, appending to macro */
+/* page offsetting is not done! */
+Fmt difmt;
+int difmtinit;
+Rune di[20][100];
+int ndi;
+
+void
+emitdi(void)
+{
+	flushdi();
+	runefmtstrinit(&difmt);
+	difmtinit = 1;
+	fmtrune(&difmt, Uformatted);
+}
+
+void
+flushdi(void)
+{
+	int n;
+	Rune *p;
+	
+	if(ndi == 0 || difmtinit == 0)
+		return;
+	fmtrune(&difmt, Uunformatted);
+	p = runefmtstrflush(&difmt);
+	memset(&difmt, 0, sizeof difmt);
+	difmtinit = 0;
+	if(p == nil)
+		warn("out of memory in diversion %C%S", dot, di[ndi-1]);
+	else{
+		n = runestrlen(p);
+		if(n > 0 && p[n-1] != '\n'){
+			p = runerealloc(p, n+2);
+			p[n] = '\n';
+			p[n+1] = 0;
+		}
+	}
+	as(di[ndi-1], p);
+	free(p);
+}
+
+void
+outdi(Rune r)
+{
+if(!difmtinit) abort();
+	if(r == Uempty)
+		return;
+	fmtrune(&difmt, r);
+}
+
+/* .di, .da */
+void
+r_di(int argc, Rune **argv)
+{
+	br();
+	if(argc > 2)
+		warn("extra arguments to %C%S", dot, argv[0]);
+	if(argc == 1){
+		/* end diversion */
+		if(ndi <= 0){
+			// warn("unmatched %C%S", dot, argv[0]);
+			return;
+		}
+		flushdi();
+		if(--ndi == 0){
+			_nr(L(".z"), nil);
+			outcb = nil;
+		}else{
+			_nr(L(".z"), di[ndi-1]);
+			runefmtstrinit(&difmt);
+			fmtrune(&difmt, Uformatted);
+			difmtinit = 1;
+		}
+		return;
+	}
+	/* start diversion */
+	/* various register state should be saved, but it's all useless to us */
+	flushdi();
+	if(ndi >= nelem(di))
+		sysfatal("%Cdi overflow", dot);
+	if(argv[0][1] == 'i')
+		ds(argv[1], nil);
+	_nr(L(".z"), argv[1]);
+	runestrcpy(di[ndi++], argv[1]);
+	runefmtstrinit(&difmt);
+	fmtrune(&difmt, Uformatted);
+	difmtinit = 1;
+	outcb = outdi;
+}
+
+/* .wh - install trap */
+/* .ch - change trap */
+/* .dt - install diversion trap */
+
+/* set input-line count trap */
+int itrapcount;
+int itrapwaiting;
+Rune *itrapname;
+
+void
+r_it(int argc, Rune **argv)
+{
+	if(argc < 3){
+		itrapcount = 0;
+		return;
+	}
+	itrapcount = eval(argv[1]);
+	free(itrapname);
+	itrapname = erunestrdup(argv[2]);
+}
+
+void
+itrap(void)
+{
+	itrapset();
+	if(itrapwaiting){
+		itrapwaiting = 0;
+		runmacro1(itrapname);
+	}
+}
+
+void
+itrapset(void)
+{
+	if(itrapcount > 0 && --itrapcount == 0)
+		itrapwaiting = 1;
+}
+
+/* .em - invoke macro when all input is over */
+void
+r_em(int argc, Rune **argv)
+{
+	Rune buf[20];
+	
+	USED(argc);
+	runesnprint(buf, nelem(buf), ".%S\n", argv[1]);
+	as(L("eof"), buf);
+}
+
+int
+e_star(void)
+{
+	Rune *p;
+	
+	p = getds(getname());
+	if(p)
+		pushinputstring(p);
+	return 0;
+}
+
+int
+e_t(void)
+{
+	if(inputmode&CopyMode)
+		return '\t';
+	return 0;
+}
+
+int
+e_a(void)
+{
+	if(inputmode&CopyMode)
+		return '\a';
+	return 0;
+}
+
+int
+e_backslash(void)
+{
+	if(inputmode&ArgMode)
+		ungetrune('\\');
+	return backslash;
+}
+
+int
+e_dot(void)
+{
+	return '.';
+}
+
+int
+e_dollar(void)
+{
+	int c;
+
+	c = getnext();
+	if(c < '1' || c > '9'){
+		ungetnext(c);
+		return 0;
+	}
+	c -= '0';
+	if(nmstack <= 0 || mstack[nmstack-1].argc <= c)
+		return 0;
+	pushinputstring(mstack[nmstack-1].argv[c]);
+	return 0;
+}
+
+void
+t7init(void)
+{	
+	addreq(L("de"), r_de, -1);
+	addreq(L("am"), r_de, -1);
+	addreq(L("ig"), r_de, -1);
+	addraw(L("ds"), r_ds);
+	addraw(L("as"), r_ds);
+	addreq(L("rm"), r_rm, -1);
+	addreq(L("rn"), r_rn, -1);
+	addreq(L("di"), r_di, -1);
+	addreq(L("da"), r_di, -1);
+	addreq(L("it"), r_it, -1);
+	addreq(L("em"), r_em, 1);
+	addreq(L("wh"), r_wh, -1);
+	addreq(L("ch"), r_ch, -1);
+	addreq(L("dt"), r_dt, -1);
+	
+	addesc('$', e_dollar, CopyMode|ArgMode|HtmlMode);
+	addesc('*', e_star, CopyMode|ArgMode|HtmlMode);
+	addesc('t', e_t, CopyMode|ArgMode);
+	addesc('a', e_a, CopyMode|ArgMode);
+	addesc('\\', e_backslash, ArgMode|CopyMode);
+	addesc('.', e_dot, CopyMode|ArgMode);
+	
+	ds(L("eof"), L(".sp 0.5i\n"));
+	ds(L(".."), L(""));
+}
+

+ 449 - 0
sys/src/cmd/htmlroff/t8.c

@@ -0,0 +1,449 @@
+#include "a.h"
+/*
+ * 8. Number Registers
+ * (Reg register implementation is also here.)
+ */
+
+/*
+ *	\nx		N
+ *	\n(xx	N
+ *	\n+x		N+=M
+ *	\n-x		N-=M
+ *
+ *	.nr R ±N M
+ *	.af R c
+ *
+ *	formats
+ *		1	0, 1, 2, 3, ...
+ *		001	001, 002, 003, ...
+ *		i	0, i, ii, iii, iv, v, ...
+ *		I	0, I, II, III, IV, V, ...
+ *		a	0, a, b, ..., aa, ab, ..., zz, aaa, ...
+ *		A	0, A, B, ..., AA, AB, ..., ZZ, AAA, ...
+ *
+ *	\gx \g(xx return format of number register
+ *
+ *	.rr R
+ */
+
+typedef struct Reg Reg;
+struct Reg
+{
+	Reg *next;
+	Rune *name;
+	Rune *val;
+	Rune *fmt;
+	int inc;
+};
+
+Reg *dslist;
+Reg *nrlist;
+
+/*
+ * Define strings and numbers.
+ */
+void
+dsnr(Rune *name, Rune *val, Reg **l)
+{
+	Reg *s;
+
+	for(s = *l; s != nil; s = *l){
+		if(runestrcmp(s->name, name) == 0)
+			break;
+		l = &s->next;
+	}
+	if(val == nil){
+		if(s){
+			*l = s->next;
+			free(s->val);
+			free(s->fmt);
+			free(s);
+		}
+		return;
+	}
+	if(s == nil){
+		s = emalloc(sizeof(Reg));
+		*l = s;
+		s->name = erunestrdup(name);
+	}else
+		free(s->val);
+	s->val = erunestrdup(val);
+}
+
+Rune*
+getdsnr(Rune *name, Reg *list)
+{
+	Reg *s;
+	
+	for(s=list; s; s=s->next)
+		if(runestrcmp(name, s->name) == 0)
+			return s->val;
+	return nil;
+}
+
+void
+ds(Rune *name, Rune *val)
+{
+	dsnr(name, val, &dslist);
+}
+
+void
+as(Rune *name, Rune *val)
+{
+	Rune *p, *q;
+	
+	p = getds(name);
+	if(p == nil)
+		p = L("");
+	q = runemalloc(runestrlen(p)+runestrlen(val)+1);
+	runestrcpy(q, p);
+	runestrcat(q, val);
+	ds(name, q);
+	free(q);
+}
+
+Rune*
+getds(Rune *name)
+{
+	return getdsnr(name, dslist);
+}
+
+void
+printds(int t)
+{
+	int n, total;
+	Reg *s;
+	
+	total = 0;
+	for(s=dslist; s; s=s->next){
+		if(s->val)
+			n = runestrlen(s->val);
+		else
+			n = 0;
+		total += n;
+		if(!t)
+			fprint(2, "%S\t%d\n", s->name, n);
+	}
+	fprint(2, "total\t%d\n", total);
+}
+
+void
+nr(Rune *name, int val)
+{
+	Rune buf[20];
+	
+	runesnprint(buf, nelem(buf), "%d", val);
+	_nr(name, buf);
+}
+
+void
+af(Rune *name, Rune *fmt)
+{
+	Reg *s;
+
+	if(_getnr(name) == nil)
+		_nr(name, L("0"));
+	for(s=nrlist; s; s=s->next)
+		if(runestrcmp(s->name, name) == 0)
+			s->fmt = erunestrdup(fmt);
+}
+
+Rune*
+getaf(Rune *name)
+{
+	Reg *s;
+	
+	for(s=nrlist; s; s=s->next)
+		if(runestrcmp(s->name, name) == 0)
+			return s->fmt;
+	return nil;
+}
+
+void
+printnr(void)
+{
+	Reg *r;
+	
+	for(r=nrlist; r; r=r->next)
+		fprint(2, "%S %S %d\n", r->name, r->val, r->inc);
+}
+
+/*
+ * Some internal number registers are actually strings,
+ * so provide _ versions to get at them.
+ */
+void
+_nr(Rune *name, Rune *val)
+{
+	dsnr(name, val, &nrlist);
+}
+
+Rune*
+_getnr(Rune *name)
+{
+	return getdsnr(name, nrlist);
+}
+
+int
+getnr(Rune *name)
+{
+	Rune *p;
+
+	p = _getnr(name);
+	if(p == nil)
+		return 0;
+	return eval(p);
+}
+
+/* new register */
+void
+r_nr(int argc, Rune **argv)
+{
+	Reg *s;
+
+	if(argc < 2)
+		return;
+	if(argc < 3)
+		nr(argv[1], 0);
+	else{
+		if(argv[2][0] == '+')
+			nr(argv[1], getnr(argv[1])+eval(argv[2]+1));
+		else if(argv[2][0] == '-')
+			nr(argv[1], getnr(argv[1])-eval(argv[2]+1));
+		else
+			nr(argv[1], eval(argv[2]));
+	}
+	if(argc > 3){
+		for(s=nrlist; s; s=s->next)
+			if(runestrcmp(s->name, argv[1]) == 0)
+				s->inc = eval(argv[3]);
+	}
+}
+
+/* assign format */
+void
+r_af(int argc, Rune **argv)
+{
+	USED(argc);
+	
+	af(argv[1], argv[2]);
+}
+
+/* remove register */
+void
+r_rr(int argc, Rune **argv)
+{
+	int i;
+	
+	for(i=1; i<argc; i++)
+		_nr(argv[i], nil);
+}
+
+/* fmt integer in base 26 */
+void
+alpha(Rune *buf, int n, int a)
+{
+	int i, v;
+	
+	i = 1;
+	for(v=n; v>0; v/=26)
+		i++;
+	if(i == 0)
+		i = 1;
+	buf[i] = 0;
+	while(i > 0){
+		buf[--i] = a+n%26;
+		n /= 26;
+	}
+}
+
+struct romanv {
+	char *s;
+	int v;
+} romanv[] =
+{
+	"m",	1000,
+	"cm", 900,
+	"d", 500,
+	"cd", 400,
+	"c", 100,
+	"xc", 90,
+	"l", 50,
+	"xl", 40,
+	"x", 10,
+	"ix", 9,
+	"v", 5,
+	"iv", 4,
+	"i", 1
+};
+
+/* fmt integer in roman numerals! */
+void
+roman(Rune *buf, int n, int upper)
+{
+	Rune *p;
+	char *q;
+	struct romanv *r;
+	
+	if(upper)
+		upper = 'A' - 'a';
+	if(n >= 5000 || n <= 0){
+		runestrcpy(buf, L("-"));
+		return;
+	}
+	p = buf;
+	r = romanv;
+	while(n > 0){
+		while(n >= r->v){
+			for(q=r->s; *q; q++)
+				*p++ = *q + upper;
+			n -= r->v;
+		}
+		r++;
+	}
+	*p = 0;
+}
+
+Rune*
+getname(void)
+{
+	int i, c, cc;
+	static Rune buf[100];
+	
+	/* XXX add [name] syntax as in groff */
+	c = getnext();
+	if(c < 0)
+		return L("");
+	if(c == '\n'){
+		warn("newline in name\n");
+		ungetnext(c);
+		return L("");
+	}
+	if(c == '['){
+		for(i=0; i<nelem(buf)-1; i++){
+			if((c = getrune()) < 0)
+				return L("");
+			if(c == ']'){
+				buf[i] = 0;
+				return buf;
+			}
+			buf[i] = c;
+		}
+		return L("");
+	}
+	if(c != '('){
+		buf[0] = c;
+		buf[1] = 0;
+		return buf;
+	}
+	c = getnext();
+	cc = getnext();
+	if(c < 0 || cc < 0)
+		return L("");
+	if(c == '\n' | cc == '\n'){
+		warn("newline in \\n");
+		ungetnext(cc);
+		if(c == '\n')
+			ungetnext(c);
+	}
+	buf[0] = c;
+	buf[1] = cc;
+	buf[2] = 0;
+	return buf;
+}
+
+/* \n - return number register */
+int
+e_n(void)
+{
+	int inc, v, l;
+	Rune *name, *fmt, buf[100];
+	Reg *s;
+	
+	inc = getnext();
+	if(inc < 0)
+		return -1;
+	if(inc != '+' && inc != '-'){
+		ungetnext(inc);
+		inc = 0;
+	}
+	name = getname();
+	if(_getnr(name) == nil)
+		_nr(name, L("0"));
+	for(s=nrlist; s; s=s->next){
+		if(runestrcmp(s->name, name) == 0){
+			if(s->fmt == nil && !inc && s->val[0]){
+				/* might be a string! */
+				pushinputstring(s->val);
+				return 0;
+			}
+			v = eval(s->val);
+			if(inc){
+				if(inc == '+')
+					v += s->inc;
+				else
+					v -= s->inc;
+				runesnprint(buf, nelem(buf), "%d", v);
+				free(s->val);
+				s->val = erunestrdup(buf);
+			}
+			fmt = s->fmt;
+			if(fmt == nil)
+				fmt = L("1");
+			switch(fmt[0]){
+			case 'i':
+			case 'I':
+				roman(buf, v, fmt[0]=='I');
+				break;
+			case 'a':
+			case 'A':
+				alpha(buf, v, fmt[0]);
+				break;
+			default:
+				l = runestrlen(fmt);
+				if(l == 0)
+					l = 1;
+				runesnprint(buf, sizeof buf, "%0*d", l, v);
+				break;
+			}
+			pushinputstring(buf);
+			return 0;
+		}
+	}
+	pushinputstring(L(""));
+	return 0;
+}
+
+/* \g - number register format */
+int
+e_g(void)
+{
+	Rune *p;
+
+	p = getaf(getname());
+	if(p == nil)
+		p = L("1");
+	pushinputstring(p);
+	return 0;
+}
+
+void
+r_pnr(int argc, Rune **argv)
+{
+	USED(argc);
+	USED(argv);
+	printnr();
+}
+
+void
+t8init(void)
+{
+	addreq(L("nr"), r_nr, -1);
+	addreq(L("af"), r_af, 2);
+	addreq(L("rr"), r_rr, -1);
+	addreq(L("pnr"), r_pnr, 0);
+	
+	addesc('n', e_n, CopyMode|ArgMode|HtmlMode);
+	addesc('g', e_g, 0);
+}
+

+ 6 - 0
sys/src/cmd/htmlroff/t9.c

@@ -0,0 +1,6 @@
+/*
+ * 9.  Tabs, leaders, and fields.
+ */
+
+XXX
+

+ 123 - 0
sys/src/cmd/htmlroff/util.c

@@ -0,0 +1,123 @@
+#include "a.h"
+
+void*
+emalloc(uint n)
+{
+	void *v;
+	
+	v = mallocz(n, 1);
+	if(v == nil)
+		sysfatal("out of memory");
+	return v;
+}
+
+char*
+estrdup(char *s)
+{
+	char *t;
+	
+	t = strdup(s);
+	if(t == nil)
+		sysfatal("out of memory");
+	return t;
+}
+
+Rune*
+erunestrdup(Rune *s)
+{
+	Rune *t;
+
+	t = emalloc(sizeof(Rune)*(runestrlen(s)+1));
+	if(t == nil)
+		sysfatal("out of memory");
+	runestrcpy(t, s);
+	return t;
+}
+
+void*
+erealloc(void *ov, uint n)
+{
+	void *v;
+	
+	v = realloc(ov, n);
+	if(v == nil)
+		sysfatal("out of memory");
+	return v;
+}
+
+Rune*
+erunesmprint(char *fmt, ...)
+{
+	Rune *s;
+	va_list arg;
+	
+	va_start(arg, fmt);
+	s = runevsmprint(fmt, arg);
+	va_end(arg);
+	if(s == nil)
+		sysfatal("out of memory");
+	return s;
+}
+
+char*
+esmprint(char *fmt, ...)
+{
+	char *s;
+	va_list arg;
+	
+	va_start(arg, fmt);
+	s = vsmprint(fmt, arg);
+	va_end(arg);
+	if(s == nil)
+		sysfatal("out of memory");
+	return s;
+}
+
+void
+warn(char *fmt, ...)
+{
+	va_list arg;
+	
+	fprint(2, "%L: ");
+	va_start(arg, fmt);
+	vfprint(2, fmt, arg);
+	va_end(arg);
+	fprint(2, "\n");
+}
+
+/*
+ * For non-Unicode compilers, so we can say
+ * L("asdf") and get a Rune string.  Assumes strings
+ * are identified by their pointers, so no mutable strings!
+ */
+typedef struct Lhash Lhash;
+struct Lhash
+{
+	char *s;
+	Lhash *next;
+	Rune r[1];
+};
+static Lhash *hash[1127];
+
+Rune*
+L(char *s)
+{
+	Rune *p;
+	Lhash *l;
+	uint h;
+
+	h = (uintptr)s%nelem(hash);
+	for(l=hash[h]; l; l=l->next)
+		if(l->s == s)
+			return l->r;
+	l = emalloc(sizeof *l+(utflen(s)+1)*sizeof(Rune));
+	p = l->r;
+	l->s = s;
+	while(*s)
+		s += chartorune(p++, s);
+	*p = 0;
+	l->next = hash[h];
+	hash[h] = l;
+	return l->r;
+}
+

+ 275 - 0
sys/src/cmd/tcs/8859.h

@@ -0,0 +1,275 @@
+long tab8859_1[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
+0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
+0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
+0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
+0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
+0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
+};
+
+long tab8859_2[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,0x0104,0x02d8,0x0141,0x00a4,0x013d,0x015a,0x00a7,
+0x00a8,0x0160,0x015e,0x0164,0x0179,0x00ad,0x017d,0x017b,
+0x00b0,0x0105,0x02db,0x0142,0x00b4,0x013e,0x015b,0x02c7,
+0x00b8,0x0161,0x015f,0x0165,0x017a,0x02dd,0x017e,0x017c,
+0x0154,0x00c1,0x00c2,0x0102,0x00c4,0x0139,0x0106,0x00c7,
+0x010c,0x00c9,0x0118,0x00cb,0x011a,0x00cd,0x00ce,0x010e,
+0x0110,0x0143,0x0147,0x00d3,0x00d4,0x0150,0x00d6,0x00d7,
+0x0158,0x016e,0x00da,0x0170,0x00dc,0x00dd,0x0162,0x00df,
+0x0155,0x00e1,0x00e2,0x0103,0x00e4,0x013a,0x0107,0x00e7,
+0x010d,0x00e9,0x0119,0x00eb,0x011b,0x00ed,0x00ee,0x010f,
+0x0111,0x0144,0x0148,0x00f3,0x00f4,0x0151,0x00f6,0x00f7,
+0x0159,0x016f,0x00fa,0x0171,0x00fc,0x00fd,0x0163,0x02d9,
+};
+
+long tab8859_3[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,0x0126,0x02d8,0x00a3,0x00a4,    -1,0x0124,0x00a7,
+0x00a8,0x0130,0x015e,0x011e,0x0134,0x00ad,    -1,0x017b,
+0x00b0,0x0127,0x00b2,0x00b3,0x00b4,0x00b5,0x0125,0x00b7,
+0x00b8,0x0131,0x015f,0x011f,0x0135,0x00bd,    -1,0x017c,
+0x00c0,0x00c1,0x00c2,    -1,0x00c4,0x010a,0x0108,0x00c7,
+0x00c8,0x00c9,0x00ca,0x00cb,0x00cc,0x00cd,0x00ce,0x00cf,
+    -1,0x00d1,0x00d2,0x00d3,0x00d4,0x0120,0x00d6,0x00d7,
+0x011c,0x00d9,0x00da,0x00db,0x00dc,0x016c,0x015c,0x00df,
+0x00e0,0x00e1,0x00e2,    -1,0x00e4,0x010b,0x0109,0x00e7,
+0x00e8,0x00e9,0x00ea,0x00eb,0x00ec,0x00ed,0x00ee,0x00ef,
+    -1,0x00f1,0x00f2,0x00f3,0x00f4,0x0121,0x00f6,0x00f7,
+0x011d,0x00f9,0x00fa,0x00fb,0x00fc,0x016d,0x015d,0x02d9,
+};
+
+long tab8859_4[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,0x0104,0x0138,0x0156,0x00a4,0x0128,0x013b,0x00a7,
+0x00a8,0x0160,0x0112,0x0122,0x0166,0x00ad,0x017d,0x00af,
+0x00b0,0x0105,0x02db,0x0157,0x00b4,0x0129,0x013c,0x02c7,
+0x00b8,0x0161,0x0113,0x0123,0x0167,0x014a,0x017e,0x014b,
+0x0100,0x00c1,0x00c2,0x00c3,0x00c4,0x00c5,0x00c6,0x012e,
+0x010c,0x00c9,0x0118,0x00cb,0x0116,0x00cd,0x00ce,0x012a,
+0x0110,0x0145,0x014c,0x0136,0x00d4,0x00d5,0x00d6,0x00d7,
+0x00d8,0x0172,0x00da,0x00db,0x00dc,0x0168,0x016a,0x00df,
+0x0101,0x00e1,0x00e2,0x00e3,0x00e4,0x00e5,0x00e6,0x012f,
+0x010d,0x00e9,0x0119,0x00eb,0x0117,0x00ed,0x00ee,0x012b,
+0x0111,0x0146,0x014d,0x0137,0x00f4,0x00f5,0x00f6,0x00f7,
+0x00f8,0x0173,0x00fa,0x00fb,0x00fc,0x0169,0x016b,0x02d9,
+};
+
+long tab8859_5[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,0x0401,0x0402,0x0403,0x0404,0x0405,0x0406,0x0407,
+0x0408,0x0409,0x040a,0x040b,0x040c,0x00ad,0x040e,0x040f,
+0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417,
+0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e,0x041f,
+0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427,
+0x0428,0x0429,0x042a,0x042b,0x042c,0x042d,0x042e,0x042f,
+0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437,
+0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e,0x043f,
+0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447,
+0x0448,0x0449,0x044a,0x044b,0x044c,0x044d,0x044e,0x044f,
+0x2116,0x0451,0x0452,0x0453,0x0454,0x0455,0x0456,0x0457,
+0x0458,0x0459,0x045a,0x045b,0x045c,0x00a7,0x045e,0x045f,
+};
+
+long tab8859_6[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,    -1,    -1,    -1,0x00a4,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,0x060c,0x00ad,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,0x061b,    -1,    -1,    -1,0x061f,
+    -1,0x0621,0x0622,0x0623,0x0624,0x0625,0x0626,0x0627,
+0x0628,0x0629,0x062a,0x062b,0x062c,0x062d,0x062e,0x062f,
+0x0630,0x0631,0x0632,0x0633,0x0634,0x0635,0x0636,0x0637,
+0x0638,0x0639,0x063a,    -1,    -1,    -1,    -1,    -1,
+0x0640,0x0641,0x0642,0x0643,0x0644,0x0645,0x0646,0x0647,
+0x0648,0x0649,0x064a,0x064b,0x064c,0x064d,0x064e,0x064f,
+0x0650,0x0651,0x0652,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+};
+
+long tab8859_7[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,0x2018,0x2019,0x00a3,    -1,    -1,0x00a6,0x00a7,
+0x00a8,0x00a9,    -1,0x00ab,0x00ac,0x00ad,    -1,0x2015,
+0x00b0,0x00b1,0x00b2,0x00b3,0x0384,0x0385,0x0386,0x00b7,
+0x0388,0x0389,0x038a,0x00bb,0x038c,0x00bd,0x038e,0x038f,
+0x0390,0x0391,0x0392,0x0393,0x0394,0x0395,0x0396,0x0397,
+0x0398,0x0399,0x039a,0x039b,0x039c,0x039d,0x039e,0x039f,
+0x03a0,0x03a1,    -1,0x03a3,0x03a4,0x03a5,0x03a6,0x03a7,
+0x03a8,0x03a9,0x03aa,0x03ab,0x03ac,0x03ad,0x03ae,0x03af,
+0x03b0,0x03b1,0x03b2,0x03b3,0x03b4,0x03b5,0x03b6,0x03b7,
+0x03b8,0x03b9,0x03ba,0x03bb,0x03bc,0x03bd,0x03be,0x03bf,
+0x03c0,0x03c1,0x03c2,0x03c3,0x03c4,0x03c5,0x03c6,0x03c7,
+0x03c8,0x03c9,0x03ca,0x03cb,0x03cc,0x03cd,0x03ce,    -1,
+};
+
+long tab8859_8[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,    -1,0x00a2,0x00a3,0x00a4,0x00a5,0x00a6,0x00a7,
+0x00a8,0x00a9,0x00d7,0x00ab,0x00ac,0x00ad,0x00ae,0x203e,
+0x00b0,0x00b1,0x00b2,0x00b3,0x00b4,0x00b5,0x00b6,0x00b7,
+0x00b8,0x00b9,0x00f7,0x00bb,0x00bc,0x00bd,0x00be,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,0x2017,
+0x05d0,0x05d1,0x05d2,0x05d3,0x05d4,0x05d5,0x05d6,0x05d7,
+0x05d8,0x05d9,0x05da,0x05db,0x05dc,0x05dd,0x05de,0x05df,
+0x05e0,0x05e1,0x05e2,0x05e3,0x05e4,0x05e5,0x05e6,0x05e7,
+0x05e8,0x05e9,0x05ea,    -1,    -1,    -1,    -1,    -1,
+};
+
+long tab8859_9[256] =
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,0x00a1,0x00a2,0x00a3,0x00a4,0x00a5,0x00a6,0x00a7,
+0x00a8,0x00a9,0x00aa,0x00ab,0x00ac,0x00ad,0x00ae,0x00af,
+0x00b0,0x00b1,0x00b2,0x00b3,0x00b4,0x00b5,0x00b6,0x00b7,
+0x00b8,0x00b9,0x00ba,0x00bb,0x00bc,0x00bd,0x00be,0x00bf,
+0x00c0,0x00c1,0x00c2,0x00c3,0x00c4,0x00c5,0x00c6,0x00c7,
+0x00c8,0x00c9,0x00ca,0x00cb,0x00cc,0x00cd,0x00ce,0x00cf,
+0x011e,0x00d1,0x00d2,0x00d3,0x00d4,0x00d5,0x00d6,0x00d7,
+0x00d8,0x00d9,0x00da,0x00db,0x00dc,0x0130,0x015e,0x00df,
+0x00e0,0x00e1,0x00e2,0x00e3,0x00e4,0x00e5,0x00e6,0x00e7,
+0x00e8,0x00e9,0x00ea,0x00eb,0x00ec,0x00ed,0x00ee,0x00ef,
+0x011f,0x00f1,0x00f2,0x00f3,0x00f4,0x00f5,0x00f6,0x00f7,
+0x00f8,0x00f9,0x00fa,0x00fb,0x00fc,0x0131,0x015f,0x00ff,
+};
+
+long tab8859_10[256] =	/* from dkuug.dk:i18n/charmaps/ISO_8859-10:1993 */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0x00a0,0x0104,0x0112,0x0122,0x012a,0x0128,0x0136,0x00a7,
+0x013b,0x0110,0x0160,0x0166,0x017d,0x00ad,0x016a,0x014a,
+0x00b0,0x0105,0x0113,0x0123,0x012b,0x0129,0x0137,0x00b7,
+0x013c,0x0110,0x0161,0x0167,0x017e,0x2014,0x016b,0x014b,
+0x0100,0x00c1,0x00c2,0x00c3,0x00c4,0x00c5,0x00c6,0x012e,
+0x010c,0x00c9,0x0118,0x00cb,0x0116,0x00cd,0x00ce,0x00cf,
+0x00d0,0x0145,0x014c,0x00d3,0x00d4,0x00d5,0x00d6,0x0168,
+0x00d8,0x0172,0x00da,0x00db,0x00dc,0x00dd,0x00de,0x00df,
+0x0101,0x00e1,0x00e2,0x00e3,0x00e4,0x00e5,0x00e6,0x012f,
+0x010d,0x00e9,0x0119,0x00eb,0x0117,0x00ed,0x00ee,0x00ef,
+0x00f0,0x0146,0x014d,0x00f3,0x00f4,0x00f5,0x00f6,0x0169,
+0x00f8,0x0173,0x00fa,0x00fb,0x00fc,0x00fd,0x00fe,0x0138,
+};
+
+
+long tab8859_15[256] =		/* from anyrhine@cs.helsinki.fi (Aki Nyrhinen) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+0xa0,0xa1,0xa2,0xa3,0x20ac,0xa5,0x0160,0xa7,0x0161,0xa9,0xaa,0xab,0xac,0xad,
+0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0x017d,0xb5,0xb6,0xb7,0x017e,0xb9,0xba,0xbb,
+0x0152,0x0153,0x0178,0xbf,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,
+0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,
+0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,
+0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,
+0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
+};

+ 0 - 27
sys/src/cmd/tcs/cyrillic.h

@@ -106,33 +106,6 @@ long tabav[256] =
 0x0401,0x0451,0x0301,0x0300,0x0301,0x0300,0x2192,0x2190,
 0x2193,0x2191,0x00f7,0x00b1,0x2116,0x00a4,    -1,    -1,
 };
-long tabcp1251[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x0402,0x0403,0x201a,0x0453,0x201e,0x2026,0x2020,0x2021,
-    -1,0x2030,0x0409,0x2039,0x040a,0x040c,0x040b,0x040f,
-0x0452,0x2018,0x2019,0x201c,0x201d,0x2022,0x2013,0x2014,
-    -1,0x2122,0x0459,0x203a,0x045a,0x045c,0x045b,0x045f,
-0x00a0,0x040e,0x045e,0x0408,0x00a4,0x0490,0x00a6,0x00a7,
-0x0401,0x00a9,0x0404,0x00ab,0x00ac,0x00ad,0x00ae,0x0407,
-0x00b0,0x00b1,0x0406,0x0456,0x0491,0x00b5,0x00b6,0x00b7,
-0x0451,0x2116,0x0454,0x00bb,0x0458,0x0405,0x0455,0x0457,
-0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417,
-0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e,0x041f,
-0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427,
-0x0428,0x0429,0x042a,0x042b,0x042c,0x042d,0x042e,0x042f,
-0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437,
-0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e,0x043f,
-0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447,
-0x0448,0x0449,0x044a,0x044b,0x044c,0x044d,0x044e,0x044f,
-};
 long tabov[256] =
 {
 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,

+ 1 - 1
sys/src/cmd/tcs/html.c

@@ -324,7 +324,7 @@ html_out(Rune *r, int n, long *x)
 		else if((s = findbyrune(*r)) != nil)
 			Bprint(&b, "&%s;", s);
 		else
-			Bprint(&b, "&#x%04x;", *r);
+			Bprint(&b, "&#%d;", *r);
 	}
 	Bflush(&b);
 }

+ 304 - 0
sys/src/cmd/tcs/misc.h

@@ -0,0 +1,304 @@
+long tabatari[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, /* accented latin */
+0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
+0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
+0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x00df, 0x0192,
+0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
+0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
+0x00e3, 0x00f5, 0x00d8, 0x00f8, 0x0153, 0x0152, 0x00c0, 0x00c3,
+0x00d5, 0x00a8, 0x00b4, 0x2020, 0x00b6, 0x00a9, 0x00ae, 0x2122,
+0x0133, 0x0132, 
+                0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, /* hebrew */
+0x05d6, 0x05d7, 0x05d8, 0x05d9, 0x05db, 0x05dc, 0x05de, 0x05e0,
+0x05e1, 0x05e2, 0x05e4, 0x05e6, 0x05e7, 0x05e8, 0x05e9, 0x05ea,
+0x05df, 0x05da, 0x05dd, 0x05e3, 0x05e5, 
+                                        0x00a7, 0x2038, 0x221e, /* math */
+0x03b1, 0x03b2, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, /* greek */
+0x03a6, 0x03b8, 0x2126, 0x03b4, 
+                                0x222e, 0x03c6, 0x2208, 0x220f, /* math */
+0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
+0x00b0, 0x2022, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x00b3, 0x00af,
+};
+long tabebcdic[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
+{
+0x00, 0x01, 0x02, 0x03, -1,   0x09, -1,   0x7f,
+-1,   -1,   -1,   0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+0x10, 0x11, 0x12, 0x13, -1,   -1,   0x08, -1,
+0x18, 0x09, -1,   -1,   0x1c, 0x1d, 0x1e, 0x1f,
+-1,   -1,   -1,   -1,   -1,   0x0a, 0x17, 0x1b,
+-1,   -1,   -1,   -1,   -1,   0x05, 0x06, 0x07,
+-1,   -1,   0x16, -1,   -1,   -1,   -1,   0x04,
+-1,   -1,   -1,   -1,   0x14, 0x15, -1,   0x1a,
+0x20, -1,   -1,   -1,   -1,   -1,   -1,   -1,
+-1,   -1,   0x5b, 0x2e, 0x3c, 0x28, 0x2b, 0x21,
+0x26, -1,   -1,   -1,   -1,   -1,   -1,   -1,
+-1,   -1,   0x5d, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* not-sign 0xac -> circumflex 0x5e */
+0x2d, 0x2f, -1,   -1,   -1,   -1,   -1,   -1,
+-1,   -1,   0x7c, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+-1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+-1,   0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+-1,   0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+0x68, 0x69, -1,   -1,   -1,   -1,   -1,   -1,
+-1,   0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+0x71, 0x72, -1,   -1,   -1,   -1,   -1,   -1,
+-1,   0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* non-spacing macron 0xaf -> tilde 0x7e */
+0x79, 0x7a, -1,   -1,   -1,   -1,   -1,   -1,
+-1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+-1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+0x48, 0x49, -1,   -1,   -1,   -1,   -1,   -1,
+0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+0x51, 0x52, -1,   -1,   -1,   -1,   -1,   -1,
+0x5c, -1,   0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+0x59, 0x5a, -1,   -1,   -1,   -1,   -1,   -1,
+0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+0x38, 0x39, -1,   -1,   -1,   -1,   -1,   -1,
+};
+long tabmacroman[256] =	/* (modified via world.std.com!choupt) from mduerst@ifi.unizh.ch (Martin J. Du"rst) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x00c4,0x00c5,0x00c7,0x00c9,0x00d1,0x00d6,0x00dc,0x00e1,
+0x00e0,0x00e2,0x00e4,0x00e3,0x00e5,0x00e7,0x00e9,0x00e8,
+0x00ea,0x00eb,0x00ed,0x00ec,0x00ee,0x00ef,0x00f1,0x00f3,
+0x00f2,0x00f4,0x00f6,0x00f5,0x00fa,0x00f9,0x00fb,0x00fc,
+0x2020,0x00b0,0x00a2,0x00a3,0x00a7,0x2022,0x00b6,0x00df,
+0x00ae,0x00a9,0x2122,0x00b4,0x00a8,0x2260,0x00c6,0x00d8,
+0x221e,0x00b1,0x2264,0x2265,0x00a5,0x00b5,0x2202,0x2211,
+0x220f,0x03c0,0x222b,0x00aa,0x00ba,0x2126,0x00e6,0x00f8,
+0x00bf,0x00a1,0x00ac,0x221a,0x0192,0x2248,0x2206,0x00ab,
+0x00bb,0x2026,0x00a0,0x00c0,0x00c3,0x00d5,0x0152,0x0153,
+0x2013,0x2014,0x2012,0x201d,0x2018,0x2019,0x00f7,0x25ca, /*2013 en dash suggested by Glenn A. Adams*/
+0x00ff,0x0178,0x2044,0x00a4,0x2039,0x203a,0xfb01,0xfb02,
+0x2021,0x00b7,0x201a,0x201e,0x2030,0x00c2,0x00ca,0x00c1,
+0x00cb,0x00c8,0x00cd,0x00ce,0x00cf,0x00cc,0x00d3,0x00d4,
+0xf7ff,0x00d2,0x00da,0x00db,0x00d9,0x0131,0x02c6,0x02dc,
+0x00af,0x02d8,0x02d9,0x02da,0x00b8,0x02dd,0x02db,0x02c7,
+};
+long tabnextstep[256] = 	/* From mduerst@ifi.unizh.ch (Martin J. Du"rst) */
+/* From NEXTSTEP Encoding Vector / Character Code Palette */
+/* quote (0027) and quoteright (2019) should be exchanged */
+/*	if visual form is considered exactly; left as is */
+/*	for compatibility with other low-end systems */
+{
+0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
+0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
+0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
+0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
+0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
+0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
+0x2007, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C7,
+0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D9,
+0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00B5, 0x00D7, 0x00F7,
+0x00A9, 0x00A1, 0x00A2, 0x00A3, 0x2044, 0x00A5, 0x0192, 0x00A7,
+0x00A4, 0x2019, 0x201C, 0x00AB, 0x2039, 0x2040, 0xFB01, 0xFB02,
+0x00AE, 0x2013, 0x2020, 0x2021, 0x00B7, 0x254E, 0x00B6, 0x2022,
+0x201A, 0x201E, 0x201D, 0x00BB, 0x2026, 0x2030, 0x00AC, 0x00BF,
+0x00B9, 0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0306, 0x0307,
+0x0308, 0x00B2, 0x030A, 0x0327, 0x00B3, 0x030B, 0x0328, 0x030C,
+0x2014, 0x00B1, 0x00BC, 0x00BD, 0x00BE, 0x00E0, 0x00E1, 0x00E2,
+0x00E3, 0x00E4, 0x00E5, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB,
+0x00EC, 0x00C6, 0x00ED, 0x00AA, 0x00EE, 0x00EF, 0x00F0, 0x00F1,
+0x0141, 0x00D8, 0x0152, 0x00BA, 0x00F2, 0x00F3, 0x00F4, 0x00F5,
+0x00F6, 0x00E6, 0x00F9, 0x00FA, 0x00FB, 0x0131, 0x00FC, 0x00FD,
+0x0142, 0x00F8, 0x0153, 0x00DF, 0x00FE, 0x00FF, 0xFFFF, 0xFFFF
+};
+long tabps2[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, /* latin-1 repertoire with forms */
+0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
+0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
+0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x00d7, 0x0192,
+0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
+0x00bf, 0x00ae, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1, 0x00c2, 0x00c0,
+0x00a9, 0x2563, 0x2551, 0x2557, 0x255d, 0x00a2, 0x00a5, 0x2510,
+0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
+0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
+0x00f0, 0x00d0, 0x00ca, 0x00cb, 0x00c8, 0x0131, 0x00cd, 0x00ce, 
+0x00cf, 0x2518, 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
+0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5, 0x00b5, 0x00fe,
+0x00de, 0x00da, 0x00db, 0x00d9, 0x00fd, 0x00dd, 0x00af, 0x00b4,
+0x00ad, 0x00b1, 0x2017, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
+0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x220e, 0x00a0,
+};
+long tabsf1[256] =	/* From Kari.Hurtta@Helsinki.FI (Kari E. Hurtta) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0xc9,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0xc4,0xd6,0xc5,0xdc,0x5f,
+0xe9,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0xe4,0xf6,0xe5,0xfc,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+};
+long tabsf2[256] =	/* from wirzeniu@cc.helsinki.fi (Lars Wirzenius) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0xc4,0xd6,0xc5,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0xe4,0xf6,0xe5,0x7e,0x7f,
+0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+};
+long tabtis620[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+  -1,   0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
+0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
+0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
+0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
+0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
+0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
+0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
+0x0e38, 0x0e39, 0x0e3a, -1,     -1,     -1,     -1,     0x0e3f,
+0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
+0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
+0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
+0x0e58, 0x0e59, 0x0e5a, 0x0e5b, -1,     -1,     -1,     -1,
+};
+long tabviet1[256] =	/* From jdo@sjc.mentorg.com (James Do) */
+{
+    -1,   0xda, 0x1ee4,     -1, 0x1eea, 0x1eec, 0x1eee,    0x7,
+    -1,     -1,    0xa,     -1,     -1,    0xc,     -1,     -1,
+    -1, 0x1ee8, 0x1ef0, 0x1ef2, 0x1ef6, 0x1ef8,   0xdd, 0x1ef4,
+    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+  0xc0, 0x1ea2,   0xc3,   0xc1, 0x1ea0, 0x1eb6, 0x1eac,   0xc8,
+0x1eba, 0x1ebc,   0xc9, 0x1eb8, 0x1ec6,   0xcc, 0x1ec8, 0x0128,
+  0xcd, 0x1eca,   0xd2, 0x1ece,   0xd5,   0xd3, 0x1ecc, 0x1ed8,
+0x1edc, 0x1ede, 0x1ee0, 0x1eda, 0x1ee2,   0xd9, 0x1ee6, 0x0168,
+  0xa0, 0x0102,   0xc2,   0xca,   0xd4, 0x01a0, 0x01af, 0x0110,
+0x0103,   0xe2,   0xea,   0xf4, 0x01a1, 0x01b0, 0x0111, 0x1eb0,
+0x0300, 0x0309, 0x0303, 0x0301, 0x0323,   0xe0, 0x1ea3,   0xe3,
+  0xe1, 0x1ea1, 0x1eb2, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eaf, 0x1eb4,
+0x1eae, 0x1ea6, 0x1ea8, 0x1eaa, 0x1ea4, 0x1ec0, 0x1eb7, 0x1ea7,
+0x1ea9, 0x1eab, 0x1ea5, 0x1ead,   0xe8, 0x1ec2, 0x1ebb, 0x1ebd,
+  0xe9, 0x1eb9, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ebf, 0x1ec7,   0xec,
+0x1ec9, 0x1ec4, 0x1ebe, 0x1ed2, 0x0129,   0xed, 0x1ecb,   0xf2,
+0x1ed4, 0x1ecf,   0xf5,   0xf3, 0x1ecd, 0x1ed3, 0x1ed5, 0x1ed7,
+0x1ed1, 0x1ed9, 0x1edd, 0x1edf, 0x1ee1, 0x1edb, 0x1ee3,   0xf9,
+0x1ed6, 0x1ee7, 0x0169,   0xfa, 0x1ee5, 0x1eeb, 0x1eed, 0x1eef,
+0x1ee9, 0x1ef1, 0x1ef3, 0x1ef7, 0x1ef9,   0xfd, 0x1ef5, 0x1ed0
+};
+long tabviet2[256] =	/* From jdo@sjc.mentorg.com (James Do) */
+{
+0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
+0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
+0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+  0xa0, 0x0102,   0xc2,   0xca,   0xd4, 0x01a0, 0x01af, 0x0110,
+0x0103,   0xe2,   0xea,   0xf4, 0x01a1, 0x01b0, 0x0111, 0x1eb0,
+0x0300, 0x0309, 0x0303, 0x0301, 0x0323,   0xe0, 0x1ea3,   0xe3,
+  0xe1, 0x1ea1, 0x1eb2, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eaf, 0x1eb4,
+0x1eae, 0x1ea6, 0x1ea8, 0x1eaa, 0x1ea4, 0x1ec0, 0x1eb7, 0x1ea7,
+0x1ea9, 0x1eab, 0x1ea5, 0x1ead,   0xe8, 0x1ec2, 0x1ebb, 0x1ebd,
+  0xe9, 0x1eb9, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ebf, 0x1ec7,   0xec,
+0x1ec9, 0x1ec4, 0x1ebe, 0x1ed2, 0x0129,   0xed, 0x1ecb,   0xf2,
+0x1ed4, 0x1ecf,   0xf5,   0xf3, 0x1ecd, 0x1ed3, 0x1ed5, 0x1ed7,
+0x1ed1, 0x1ed9, 0x1edd, 0x1edf, 0x1ee1, 0x1edb, 0x1ee3,   0xf9,
+0x1ed6, 0x1ee7, 0x0169,   0xfa, 0x1ee5, 0x1eeb, 0x1eed, 0x1eef,
+0x1ee9, 0x1ef1, 0x1ef3, 0x1ef7, 0x1ef9,   0xfd, 0x1ef5, 0x1ed0
+};
+long tabviscii[256] =	/* From cuong@haydn.Stanford.EDU (Cuong T. Nguyen) */
+{
+0x0000, 0x0001, 0x1EB2, 0x0003, 0x0004, 0x1EB4, 0x1EAA, 0x0007,
+0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+0x0010, 0x0011, 0x0012, 0x0013, 0x1EF6, 0x0015, 0x0016, 0x0017,
+0x0018, 0x1EF8, 0x001a, 0x001b, 0x001c, 0x001d, 0x1EF4, 0x001f,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
+0x1EA0, 0x1EAE, 0x1EB0, 0x1EB6, 0x1EA4, 0x1EA6, 0x1EA8, 0x1EAC,
+0x1EBC, 0x1EB8, 0x1EBE, 0x1EC0, 0x1EC2, 0x1EC4, 0x1EC6, 0x1ED0,
+0x1ED2, 0x1ED4, 0x1ED6, 0x1ED8, 0x1EE2, 0x1EDA, 0x1EDC, 0x1EDE,
+0x1ECA, 0x1ECE, 0x1ECC, 0x1EC8, 0x1EE6, 0x0168, 0x1EE4, 0x1EF2,
+0x00D5, 0x1EAF, 0x1EB1, 0x1EB7, 0x1EA5, 0x1EA7, 0x1EA9, 0x1EAD,
+0x1EBD, 0x1EB9, 0x1EBF, 0x1EC1, 0x1EC3, 0x1EC5, 0x1EC7, 0x1ED1,
+0x1ED3, 0x1ED5, 0x1ED7, 0x1EE0, 0x01A0, 0x1ED9, 0x1EDD, 0x1EDF,
+0x1ECB, 0x1EF0, 0x1EE8, 0x1EEA, 0x1EEC, 0x01A1, 0x1EDB, 0x01AF,
+0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x1EA2, 0x0102, 0x1EB3, 0x1EB5,
+0x00C8, 0x00C9, 0x00CA, 0x1EBA, 0x00CC, 0x00CD, 0x0128, 0x1EF3,
+0x0110, 0x1EE9, 0x00D2, 0x00D3, 0x00D4, 0x1EA1, 0x1EF7, 0x1EEB,
+0x1EED, 0x00D9, 0x00DA, 0x1EF9, 0x1EF5, 0x00DD, 0x1EE1, 0x01B0,
+0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x1EA3, 0x0103, 0x1EEF, 0x1EAB,
+0x00E8, 0x00E9, 0x00EA, 0x1EBB, 0x00EC, 0x00ED, 0x0129, 0x1EC9,
+0x0111, 0x1EF1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x1ECF, 0x1ECD,
+0x1EE5, 0x00F9, 0x00FA, 0x0169, 0x1EE7, 0x00FD, 0x1EE3, 0x1EEE
+};

+ 3 - 0
sys/src/cmd/tcs/mkfile

@@ -24,6 +24,9 @@ tcs.$O big5.$O:		big5.h
 tcs.$O gb.$O:		gb.h
 tcs.$O:			cyrillic.h
 tcs.$O:			conv.h
+tcs.$O:			8859.h
+tcs.$O:			ms.h
+tcs.$O:			misc.h
 conv%.$O:		conv.h
 conv_ksc.$O:		ksc.h
 

+ 737 - 0
sys/src/cmd/tcs/ms.h

@@ -0,0 +1,737 @@
+/*
+#!/usr/local/plan9/bin/rc
+
+# $1 is oem/437 or sbcs/1252 (windows)
+for(i in $*){
+	j=`{echo $i | sed 's;.*./;cp;'}
+	echo long tab$j'[256] = {'
+	hget http://www.microsoft.com/globaldev/reference/$i.mspx | htmlfmt | 
+		9 grep '^.. = U\+....:' | 9 sed 's/= U\+/ 0x/; s/:.*.//' | awk '
+			{ t[$1] = $2 }
+			END { 
+				for(i=0; i<256; i++) {
+					s = sprintf("%.2X", i);
+					if(s in t)
+						printf("%s,\n", t[s])
+					else
+						printf("****-1,\n");
+				}
+			}
+		' | 9 fmt -l 70 | tr '*' ' '
+	echo '};'
+}
+*/
+long tabcp437[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
+0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp720[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+    -1,     -1, 0x00E9, 0x00E2,     -1, 0x00E0,     -1, 0x00E7,
+0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE,     -1,     -1,     -1,
+    -1, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9,
+0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627,
+0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
+0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642,
+0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A,
+0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248,
+0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp737[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
+0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
+0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
+0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,
+0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0,
+0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD,
+0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,
+0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248,
+0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp775[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107,
+0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
+0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A,
+0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,
+0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6,
+0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118,
+0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,
+0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B,
+0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144,
+0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,
+0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E,
+0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp850[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
+0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
+0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
+0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
+0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
+0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
+0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
+0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp852[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7,
+0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
+0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A,
+0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,
+0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E,
+0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A,
+0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE,
+0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,
+0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161,
+0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,
+0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8,
+0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0,
+};
+long tabcp855[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
+0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
+0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C,
+0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,
+0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414,
+0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438,
+0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E,
+0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,
+0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443,
+0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,
+0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D,
+0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0,
+};
+long tabcp857[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
+0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,
+0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F,
+0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
+0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8,     -1, 0x00CD, 0x00CE,
+0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
+0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5,     -1,
+0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,
+0x00AD, 0x00B1,     -1, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
+0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp858[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
+0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
+0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
+0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
+0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
+0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
+0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
+0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp862[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
+0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
+0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
+0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
+0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0,
+};
+long tabcp866[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E,
+0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0,
+};
+long tabcp874[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1,     -1,     -1,     -1, 0x2026,     -1,     -1,
+    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
+0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
+0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
+0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
+0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+0x0E38, 0x0E39, 0x0E3A,     -1,     -1,     -1,     -1, 0x0E3F,
+0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
+0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
+0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
+0x0E58, 0x0E59, 0x0E5A, 0x0E5B,     -1,     -1,     -1,     -1,
+};
+long tabcp1250[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1, 0x201A,     -1, 0x201E, 0x2026, 0x2020, 0x2021,
+    -1, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+    -1, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
+0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7,
+0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
+0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
+0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
+0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
+0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
+0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
+0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
+0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
+0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
+0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9,
+};
+long tabcp1251[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
+0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
+0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+    -1, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
+0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
+0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
+0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
+0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
+0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+};
+long tabcp1252[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+0x02C6, 0x2030, 0x0160, 0x2039, 0x0152,     -1, 0x017D,     -1,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+0x02DC, 0x2122, 0x0161, 0x203A, 0x0153,     -1, 0x017E, 0x0178,
+0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
+0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF,
+};
+long tabcp1253[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+    -1, 0x2030,     -1, 0x2039,     -1,     -1,     -1,     -1,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+    -1, 0x2122,     -1, 0x203A,     -1,     -1,     -1,     -1,
+0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+0x00A8, 0x00A9,     -1, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
+0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7,
+0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
+0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+0x03A0, 0x03A1,     -1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
+0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
+0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
+0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE,     -1,
+};
+long tabcp1254[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+0x02C6, 0x2030, 0x0160, 0x2039, 0x0152,     -1,     -1,     -1,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+0x02DC, 0x2122, 0x0161, 0x203A, 0x0153,     -1,     -1, 0x0178,
+0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF,
+0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF,
+};
+long tabcp1255[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+0x02C6, 0x2030,     -1, 0x2039,     -1,     -1,     -1,     -1,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+0x02DC, 0x2122,     -1, 0x203A,     -1,     -1,     -1,     -1,
+0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7,
+0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
+0x05B8, 0x05B9,     -1, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
+0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3,
+0x05F4,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
+0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
+0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
+0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
+0x05E8, 0x05E9, 0x05EA,     -1,     -1, 0x200E, 0x200F,     -1,
+};
+long tabcp1256[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
+0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA,
+0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F,
+0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
+0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7,
+0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643,
+0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7,
+0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
+0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7,
+0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2,
+};
+long tabcp1257[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1, 0x201A,     -1, 0x201E, 0x2026, 0x2020, 0x2021,
+    -1, 0x2030,     -1, 0x2039,     -1, 0x00A8, 0x02C7, 0x00B8,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+    -1, 0x2122,     -1, 0x203A,     -1, 0x00AF, 0x02DB,     -1,
+0x00A0,     -1, 0x00A2, 0x00A3, 0x00A4,     -1, 0x00A6, 0x00A7,
+0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
+0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
+0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
+0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
+0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7,
+0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
+0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113,
+0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
+0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7,
+0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9,
+};
+long tabcp1258[256] = {
+0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+0x20AC,     -1, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+0x02C6, 0x2030,     -1, 0x2039, 0x0152,     -1,     -1,     -1,
+    -1, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+0x02DC, 0x2122,     -1, 0x203A, 0x0153,     -1,     -1, 0x0178,
+0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF,
+0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7,
+0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF,
+0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF,
+0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
+0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF,
+};

+ 29 - 655
sys/src/cmd/tcs/tcs.c

@@ -13,6 +13,9 @@
 #include	<bio.h>
 #endif /* PLAN9 */
 #include	"cyrillic.h"
+#include	"misc.h"
+#include	"ms.h"
+#include	"8859.h"
 #include	"big5.h"
 #include	"gb.h"
 #include	"hdr.h"
@@ -325,375 +328,6 @@ long tabascii[256] =
   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
 };
 
-long tab8859_1[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
-0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
-0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
-0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
-0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
-0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
-};
-
-long tab8859_2[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,0x0104,0x02d8,0x0141,0x00a4,0x013d,0x015a,0x00a7,
-0x00a8,0x0160,0x015e,0x0164,0x0179,0x00ad,0x017d,0x017b,
-0x00b0,0x0105,0x02db,0x0142,0x00b4,0x013e,0x015b,0x02c7,
-0x00b8,0x0161,0x015f,0x0165,0x017a,0x02dd,0x017e,0x017c,
-0x0154,0x00c1,0x00c2,0x0102,0x00c4,0x0139,0x0106,0x00c7,
-0x010c,0x00c9,0x0118,0x00cb,0x011a,0x00cd,0x00ce,0x010e,
-0x0110,0x0143,0x0147,0x00d3,0x00d4,0x0150,0x00d6,0x00d7,
-0x0158,0x016e,0x00da,0x0170,0x00dc,0x00dd,0x0162,0x00df,
-0x0155,0x00e1,0x00e2,0x0103,0x00e4,0x013a,0x0107,0x00e7,
-0x010d,0x00e9,0x0119,0x00eb,0x011b,0x00ed,0x00ee,0x010f,
-0x0111,0x0144,0x0148,0x00f3,0x00f4,0x0151,0x00f6,0x00f7,
-0x0159,0x016f,0x00fa,0x0171,0x00fc,0x00fd,0x0163,0x02d9,
-};
-
-long tab8859_3[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,0x0126,0x02d8,0x00a3,0x00a4,    -1,0x0124,0x00a7,
-0x00a8,0x0130,0x015e,0x011e,0x0134,0x00ad,    -1,0x017b,
-0x00b0,0x0127,0x00b2,0x00b3,0x00b4,0x00b5,0x0125,0x00b7,
-0x00b8,0x0131,0x015f,0x011f,0x0135,0x00bd,    -1,0x017c,
-0x00c0,0x00c1,0x00c2,    -1,0x00c4,0x010a,0x0108,0x00c7,
-0x00c8,0x00c9,0x00ca,0x00cb,0x00cc,0x00cd,0x00ce,0x00cf,
-    -1,0x00d1,0x00d2,0x00d3,0x00d4,0x0120,0x00d6,0x00d7,
-0x011c,0x00d9,0x00da,0x00db,0x00dc,0x016c,0x015c,0x00df,
-0x00e0,0x00e1,0x00e2,    -1,0x00e4,0x010b,0x0109,0x00e7,
-0x00e8,0x00e9,0x00ea,0x00eb,0x00ec,0x00ed,0x00ee,0x00ef,
-    -1,0x00f1,0x00f2,0x00f3,0x00f4,0x0121,0x00f6,0x00f7,
-0x011d,0x00f9,0x00fa,0x00fb,0x00fc,0x016d,0x015d,0x02d9,
-};
-
-long tab8859_4[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,0x0104,0x0138,0x0156,0x00a4,0x0128,0x013b,0x00a7,
-0x00a8,0x0160,0x0112,0x0122,0x0166,0x00ad,0x017d,0x00af,
-0x00b0,0x0105,0x02db,0x0157,0x00b4,0x0129,0x013c,0x02c7,
-0x00b8,0x0161,0x0113,0x0123,0x0167,0x014a,0x017e,0x014b,
-0x0100,0x00c1,0x00c2,0x00c3,0x00c4,0x00c5,0x00c6,0x012e,
-0x010c,0x00c9,0x0118,0x00cb,0x0116,0x00cd,0x00ce,0x012a,
-0x0110,0x0145,0x014c,0x0136,0x00d4,0x00d5,0x00d6,0x00d7,
-0x00d8,0x0172,0x00da,0x00db,0x00dc,0x0168,0x016a,0x00df,
-0x0101,0x00e1,0x00e2,0x00e3,0x00e4,0x00e5,0x00e6,0x012f,
-0x010d,0x00e9,0x0119,0x00eb,0x0117,0x00ed,0x00ee,0x012b,
-0x0111,0x0146,0x014d,0x0137,0x00f4,0x00f5,0x00f6,0x00f7,
-0x00f8,0x0173,0x00fa,0x00fb,0x00fc,0x0169,0x016b,0x02d9,
-};
-
-long tab8859_5[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,0x0401,0x0402,0x0403,0x0404,0x0405,0x0406,0x0407,
-0x0408,0x0409,0x040a,0x040b,0x040c,0x00ad,0x040e,0x040f,
-0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417,
-0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e,0x041f,
-0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427,
-0x0428,0x0429,0x042a,0x042b,0x042c,0x042d,0x042e,0x042f,
-0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437,
-0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e,0x043f,
-0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447,
-0x0448,0x0449,0x044a,0x044b,0x044c,0x044d,0x044e,0x044f,
-0x2116,0x0451,0x0452,0x0453,0x0454,0x0455,0x0456,0x0457,
-0x0458,0x0459,0x045a,0x045b,0x045c,0x00a7,0x045e,0x045f,
-};
-
-long tab8859_6[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,    -1,    -1,    -1,0x00a4,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,0x060c,0x00ad,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,0x061b,    -1,    -1,    -1,0x061f,
-    -1,0x0621,0x0622,0x0623,0x0624,0x0625,0x0626,0x0627,
-0x0628,0x0629,0x062a,0x062b,0x062c,0x062d,0x062e,0x062f,
-0x0630,0x0631,0x0632,0x0633,0x0634,0x0635,0x0636,0x0637,
-0x0638,0x0639,0x063a,    -1,    -1,    -1,    -1,    -1,
-0x0640,0x0641,0x0642,0x0643,0x0644,0x0645,0x0646,0x0647,
-0x0648,0x0649,0x064a,0x064b,0x064c,0x064d,0x064e,0x064f,
-0x0650,0x0651,0x0652,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-};
-
-long tab8859_7[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,0x2018,0x2019,0x00a3,    -1,    -1,0x00a6,0x00a7,
-0x00a8,0x00a9,    -1,0x00ab,0x00ac,0x00ad,    -1,0x2015,
-0x00b0,0x00b1,0x00b2,0x00b3,0x0384,0x0385,0x0386,0x00b7,
-0x0388,0x0389,0x038a,0x00bb,0x038c,0x00bd,0x038e,0x038f,
-0x0390,0x0391,0x0392,0x0393,0x0394,0x0395,0x0396,0x0397,
-0x0398,0x0399,0x039a,0x039b,0x039c,0x039d,0x039e,0x039f,
-0x03a0,0x03a1,    -1,0x03a3,0x03a4,0x03a5,0x03a6,0x03a7,
-0x03a8,0x03a9,0x03aa,0x03ab,0x03ac,0x03ad,0x03ae,0x03af,
-0x03b0,0x03b1,0x03b2,0x03b3,0x03b4,0x03b5,0x03b6,0x03b7,
-0x03b8,0x03b9,0x03ba,0x03bb,0x03bc,0x03bd,0x03be,0x03bf,
-0x03c0,0x03c1,0x03c2,0x03c3,0x03c4,0x03c5,0x03c6,0x03c7,
-0x03c8,0x03c9,0x03ca,0x03cb,0x03cc,0x03cd,0x03ce,    -1,
-};
-
-long tab8859_8[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,    -1,0x00a2,0x00a3,0x00a4,0x00a5,0x00a6,0x00a7,
-0x00a8,0x00a9,0x00d7,0x00ab,0x00ac,0x00ad,0x00ae,0x203e,
-0x00b0,0x00b1,0x00b2,0x00b3,0x00b4,0x00b5,0x00b6,0x00b7,
-0x00b8,0x00b9,0x00f7,0x00bb,0x00bc,0x00bd,0x00be,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,0x2017,
-0x05d0,0x05d1,0x05d2,0x05d3,0x05d4,0x05d5,0x05d6,0x05d7,
-0x05d8,0x05d9,0x05da,0x05db,0x05dc,0x05dd,0x05de,0x05df,
-0x05e0,0x05e1,0x05e2,0x05e3,0x05e4,0x05e5,0x05e6,0x05e7,
-0x05e8,0x05e9,0x05ea,    -1,    -1,    -1,    -1,    -1,
-};
-
-long tab8859_9[256] =
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,0x00a1,0x00a2,0x00a3,0x00a4,0x00a5,0x00a6,0x00a7,
-0x00a8,0x00a9,0x00aa,0x00ab,0x00ac,0x00ad,0x00ae,0x00af,
-0x00b0,0x00b1,0x00b2,0x00b3,0x00b4,0x00b5,0x00b6,0x00b7,
-0x00b8,0x00b9,0x00ba,0x00bb,0x00bc,0x00bd,0x00be,0x00bf,
-0x00c0,0x00c1,0x00c2,0x00c3,0x00c4,0x00c5,0x00c6,0x00c7,
-0x00c8,0x00c9,0x00ca,0x00cb,0x00cc,0x00cd,0x00ce,0x00cf,
-0x011e,0x00d1,0x00d2,0x00d3,0x00d4,0x00d5,0x00d6,0x00d7,
-0x00d8,0x00d9,0x00da,0x00db,0x00dc,0x0130,0x015e,0x00df,
-0x00e0,0x00e1,0x00e2,0x00e3,0x00e4,0x00e5,0x00e6,0x00e7,
-0x00e8,0x00e9,0x00ea,0x00eb,0x00ec,0x00ed,0x00ee,0x00ef,
-0x011f,0x00f1,0x00f2,0x00f3,0x00f4,0x00f5,0x00f6,0x00f7,
-0x00f8,0x00f9,0x00fa,0x00fb,0x00fc,0x0131,0x015f,0x00ff,
-};
-long	microsoft[256] =	/* from seanq */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x0020,	0x0021,	0x0022,	0x0023,	0x0024,	0x0025,	0x0026,	0x0027,
-0x0028,	0x0029,	0x002a,	0x002b,	0x002c,	0x002d,	0x002e,	0x002f,
-0x0030,	0x0031,	0x0032,	0x0033,	0x0034,	0x0035,	0x0036,	0x0037,
-0x0038,	0x0039,	0x003a,	0x003b,	0x003c,	0x003d,	0x003e,	0x003f,
-0x0040,	0x0041,	0x0042,	0x0043,	0x0044,	0x0045,	0x0046,	0x0047,
-0x0048,	0x0049,	0x004a,	0x004b,	0x004c,	0x004d,	0x004e,	0x004f,
-0x0050,	0x0051,	0x0052,	0x0053,	0x0054,	0x0055,	0x0056,	0x0057,
-0x0058,	0x0059,	0x005a,	0x005b,	0x005c,	0x005d,	0x005e,	0x005f,
-0x0060,	0x0061,	0x0062,	0x0063,	0x0064,	0x0065,	0x0066,	0x0067,
-0x0068,	0x0069,	0x006a,	0x006b,	0x006c,	0x006d,	0x006e,	0x006f,
-0x0070,	0x0071,	0x0072,	0x0073,	0x0074,	0x0075,	0x0076,	0x0077,
-0x0078,	0x0079,	0x007a,	0x007b,	0x007c,	0x007d,	0x007e,	0x2022,
-0x2022,	0x2022,	0x201a,	0x0192,	0x201e,	0x2026,	0x2020,	0x2021,
-0x02c6,	0x2030,	0x0160,	0x2039,	0x0152,	0x2022,	0x2022,	0x2022,
-0x2022, 0x2018,	0x2019,	0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
-0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x2022, 0x2022, 0x0178,
-0x00a0,	0x00a1,	0x00a2,	0x00a3,	0x00a4,	0x00a5,	0x00a6,	0x00a7,
-0x00a8,	0x00a9,	0x00aa,	0x00ab,	0x00ac,	0x00ad,	0x00ae,	0x00af,
-0x00b0,	0x00b1,	0x00b2,	0x00b3,	0x00b4,	0x00b5,	0x00b6,	0x00b7,
-0x00b8,	0x00b9,	0x00ba,	0x00bb,	0x00bc,	0x00bd,	0x00be,	0x00bf,
-0x00c0,	0x00c1,	0x00c2,	0x00c3,	0x00c4,	0x00c5,	0x00c6,	0x00c7,
-0x00c8,	0x00c9,	0x00ca,	0x00cb,	0x00cc,	0x00cd,	0x00ce,	0x00cf,
-0x00d0,	0x00d1,	0x00d2,	0x00d3,	0x00d4,	0x00d5,	0x00d6,	0x00d7,
-0x00d8,	0x00d9,	0x00da,	0x00db,	0x00dc,	0x00dd,	0x00de,	0x00df,
-0x00e0,	0x00e1,	0x00e2,	0x00e3,	0x00e4,	0x00e5,	0x00e6,	0x00e7,
-0x00e8,	0x00e9,	0x00ea,	0x00eb,	0x00ec,	0x00ed,	0x00ee,	0x00ef,
-0x00f0,	0x00f1,	0x00f2,	0x00f3,	0x00f4,	0x00f5,	0x00f6,	0x00f7,
-0x00f8,	0x00f9,	0x00fa,	0x00fb,	0x00fc,	0x00fd,	0x00fe,	0x00ff,
-};
-long tabsf2[256] =	/* from wirzeniu@cc.helsinki.fi (Lars Wirzenius) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0xc4,0xd6,0xc5,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0xe4,0xf6,0xe5,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-};
-long tabtis620[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,   0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
-0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
-0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
-0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
-0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
-0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
-0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
-0x0e38, 0x0e39, 0x0e3a, -1,     -1,     -1,     -1,     0x0e3f,
-0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
-0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
-0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
-0x0e58, 0x0e59, 0x0e5a, 0x0e5b, -1,     -1,     -1,     -1,
-};
-long tabatari[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, /* accented latin */
-0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
-0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
-0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x00df, 0x0192,
-0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
-0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
-0x00e3, 0x00f5, 0x00d8, 0x00f8, 0x0153, 0x0152, 0x00c0, 0x00c3,
-0x00d5, 0x00a8, 0x00b4, 0x2020, 0x00b6, 0x00a9, 0x00ae, 0x2122,
-0x0133, 0x0132, 
-                0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, /* hebrew */
-0x05d6, 0x05d7, 0x05d8, 0x05d9, 0x05db, 0x05dc, 0x05de, 0x05e0,
-0x05e1, 0x05e2, 0x05e4, 0x05e6, 0x05e7, 0x05e8, 0x05e9, 0x05ea,
-0x05df, 0x05da, 0x05dd, 0x05e3, 0x05e5, 
-                                        0x00a7, 0x2038, 0x221e, /* math */
-0x03b1, 0x03b2, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, /* greek */
-0x03a6, 0x03b8, 0x2126, 0x03b4, 
-                                0x222e, 0x03c6, 0x2208, 0x220f, /* math */
-0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
-0x00b0, 0x2022, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x00b3, 0x00af,
-};
-long tabebcdic[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
-{
-0x00, 0x01, 0x02, 0x03, -1,   0x09, -1,   0x7f,
--1,   -1,   -1,   0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-0x10, 0x11, 0x12, 0x13, -1,   -1,   0x08, -1,
-0x18, 0x09, -1,   -1,   0x1c, 0x1d, 0x1e, 0x1f,
--1,   -1,   -1,   -1,   -1,   0x0a, 0x17, 0x1b,
--1,   -1,   -1,   -1,   -1,   0x05, 0x06, 0x07,
--1,   -1,   0x16, -1,   -1,   -1,   -1,   0x04,
--1,   -1,   -1,   -1,   0x14, 0x15, -1,   0x1a,
-0x20, -1,   -1,   -1,   -1,   -1,   -1,   -1,
--1,   -1,   0x5b, 0x2e, 0x3c, 0x28, 0x2b, 0x21,
-0x26, -1,   -1,   -1,   -1,   -1,   -1,   -1,
--1,   -1,   0x5d, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* not-sign 0xac -> circumflex 0x5e */
-0x2d, 0x2f, -1,   -1,   -1,   -1,   -1,   -1,
--1,   -1,   0x7c, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
--1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
--1,   0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
--1,   0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
-0x68, 0x69, -1,   -1,   -1,   -1,   -1,   -1,
--1,   0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
-0x71, 0x72, -1,   -1,   -1,   -1,   -1,   -1,
--1,   0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* non-spacing macron 0xaf -> tilde 0x7e */
-0x79, 0x7a, -1,   -1,   -1,   -1,   -1,   -1,
--1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
--1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
-0x48, 0x49, -1,   -1,   -1,   -1,   -1,   -1,
-0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
-0x51, 0x52, -1,   -1,   -1,   -1,   -1,   -1,
-0x5c, -1,   0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-0x59, 0x5a, -1,   -1,   -1,   -1,   -1,   -1,
-0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-0x38, 0x39, -1,   -1,   -1,   -1,   -1,   -1,
-};
 long tabmsdos[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
 {
 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
@@ -750,284 +384,6 @@ long tabmsdos2[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248, /* math */
 0x00b0, 0x2022, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x220e, 0x00a0,
 };
-long tabps2[256] =	/* from jhelling@cs.ruu.nl (Jeroen Hellingman) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, /* latin-1 repertoire with forms */
-0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
-0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
-0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x00d7, 0x0192,
-0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
-0x00bf, 0x00ae, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
-0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1, 0x00c2, 0x00c0,
-0x00a9, 0x2563, 0x2551, 0x2557, 0x255d, 0x00a2, 0x00a5, 0x2510,
-0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
-0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
-0x00f0, 0x00d0, 0x00ca, 0x00cb, 0x00c8, 0x0131, 0x00cd, 0x00ce, 
-0x00cf, 0x2518, 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
-0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5, 0x00b5, 0x00fe,
-0x00de, 0x00da, 0x00db, 0x00d9, 0x00fd, 0x00dd, 0x00af, 0x00b4,
-0x00ad, 0x00b1, 0x2017, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
-0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x220e, 0x00a0,
-};
-long tabsf1[256] =	/* From Kari.Hurtta@Helsinki.FI (Kari E. Hurtta) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0xc9,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0xc4,0xd6,0xc5,0xdc,0x5f,
-0xe9,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0xe4,0xf6,0xe5,0xfc,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-};
-long tabviet1[256] =	/* From jdo@sjc.mentorg.com (James Do) */
-{
-    -1,   0xda, 0x1ee4,     -1, 0x1eea, 0x1eec, 0x1eee,    0x7,
-    -1,     -1,    0xa,     -1,     -1,    0xc,     -1,     -1,
-    -1, 0x1ee8, 0x1ef0, 0x1ef2, 0x1ef6, 0x1ef8,   0xdd, 0x1ef4,
-    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-  0xc0, 0x1ea2,   0xc3,   0xc1, 0x1ea0, 0x1eb6, 0x1eac,   0xc8,
-0x1eba, 0x1ebc,   0xc9, 0x1eb8, 0x1ec6,   0xcc, 0x1ec8, 0x0128,
-  0xcd, 0x1eca,   0xd2, 0x1ece,   0xd5,   0xd3, 0x1ecc, 0x1ed8,
-0x1edc, 0x1ede, 0x1ee0, 0x1eda, 0x1ee2,   0xd9, 0x1ee6, 0x0168,
-  0xa0, 0x0102,   0xc2,   0xca,   0xd4, 0x01a0, 0x01af, 0x0110,
-0x0103,   0xe2,   0xea,   0xf4, 0x01a1, 0x01b0, 0x0111, 0x1eb0,
-0x0300, 0x0309, 0x0303, 0x0301, 0x0323,   0xe0, 0x1ea3,   0xe3,
-  0xe1, 0x1ea1, 0x1eb2, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eaf, 0x1eb4,
-0x1eae, 0x1ea6, 0x1ea8, 0x1eaa, 0x1ea4, 0x1ec0, 0x1eb7, 0x1ea7,
-0x1ea9, 0x1eab, 0x1ea5, 0x1ead,   0xe8, 0x1ec2, 0x1ebb, 0x1ebd,
-  0xe9, 0x1eb9, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ebf, 0x1ec7,   0xec,
-0x1ec9, 0x1ec4, 0x1ebe, 0x1ed2, 0x0129,   0xed, 0x1ecb,   0xf2,
-0x1ed4, 0x1ecf,   0xf5,   0xf3, 0x1ecd, 0x1ed3, 0x1ed5, 0x1ed7,
-0x1ed1, 0x1ed9, 0x1edd, 0x1edf, 0x1ee1, 0x1edb, 0x1ee3,   0xf9,
-0x1ed6, 0x1ee7, 0x0169,   0xfa, 0x1ee5, 0x1eeb, 0x1eed, 0x1eef,
-0x1ee9, 0x1ef1, 0x1ef3, 0x1ef7, 0x1ef9,   0xfd, 0x1ef5, 0x1ed0
-};
-long tabviet2[256] =	/* From jdo@sjc.mentorg.com (James Do) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
-    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
-    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
-    -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
-  0xa0, 0x0102,   0xc2,   0xca,   0xd4, 0x01a0, 0x01af, 0x0110,
-0x0103,   0xe2,   0xea,   0xf4, 0x01a1, 0x01b0, 0x0111, 0x1eb0,
-0x0300, 0x0309, 0x0303, 0x0301, 0x0323,   0xe0, 0x1ea3,   0xe3,
-  0xe1, 0x1ea1, 0x1eb2, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eaf, 0x1eb4,
-0x1eae, 0x1ea6, 0x1ea8, 0x1eaa, 0x1ea4, 0x1ec0, 0x1eb7, 0x1ea7,
-0x1ea9, 0x1eab, 0x1ea5, 0x1ead,   0xe8, 0x1ec2, 0x1ebb, 0x1ebd,
-  0xe9, 0x1eb9, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ebf, 0x1ec7,   0xec,
-0x1ec9, 0x1ec4, 0x1ebe, 0x1ed2, 0x0129,   0xed, 0x1ecb,   0xf2,
-0x1ed4, 0x1ecf,   0xf5,   0xf3, 0x1ecd, 0x1ed3, 0x1ed5, 0x1ed7,
-0x1ed1, 0x1ed9, 0x1edd, 0x1edf, 0x1ee1, 0x1edb, 0x1ee3,   0xf9,
-0x1ed6, 0x1ee7, 0x0169,   0xfa, 0x1ee5, 0x1eeb, 0x1eed, 0x1eef,
-0x1ee9, 0x1ef1, 0x1ef3, 0x1ef7, 0x1ef9,   0xfd, 0x1ef5, 0x1ed0
-};
-long tabviscii[256] =	/* From cuong@haydn.Stanford.EDU (Cuong T. Nguyen) */
-{
-0x0000, 0x0001, 0x1EB2, 0x0003, 0x0004, 0x1EB4, 0x1EAA, 0x0007,
-0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
-0x0010, 0x0011, 0x0012, 0x0013, 0x1EF6, 0x0015, 0x0016, 0x0017,
-0x0018, 0x1EF8, 0x001a, 0x001b, 0x001c, 0x001d, 0x1EF4, 0x001f,
-0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
-0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
-0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
-0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
-0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
-0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
-0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
-0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
-0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
-0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
-0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
-0x1EA0, 0x1EAE, 0x1EB0, 0x1EB6, 0x1EA4, 0x1EA6, 0x1EA8, 0x1EAC,
-0x1EBC, 0x1EB8, 0x1EBE, 0x1EC0, 0x1EC2, 0x1EC4, 0x1EC6, 0x1ED0,
-0x1ED2, 0x1ED4, 0x1ED6, 0x1ED8, 0x1EE2, 0x1EDA, 0x1EDC, 0x1EDE,
-0x1ECA, 0x1ECE, 0x1ECC, 0x1EC8, 0x1EE6, 0x0168, 0x1EE4, 0x1EF2,
-0x00D5, 0x1EAF, 0x1EB1, 0x1EB7, 0x1EA5, 0x1EA7, 0x1EA9, 0x1EAD,
-0x1EBD, 0x1EB9, 0x1EBF, 0x1EC1, 0x1EC3, 0x1EC5, 0x1EC7, 0x1ED1,
-0x1ED3, 0x1ED5, 0x1ED7, 0x1EE0, 0x01A0, 0x1ED9, 0x1EDD, 0x1EDF,
-0x1ECB, 0x1EF0, 0x1EE8, 0x1EEA, 0x1EEC, 0x01A1, 0x1EDB, 0x01AF,
-0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x1EA2, 0x0102, 0x1EB3, 0x1EB5,
-0x00C8, 0x00C9, 0x00CA, 0x1EBA, 0x00CC, 0x00CD, 0x0128, 0x1EF3,
-0x0110, 0x1EE9, 0x00D2, 0x00D3, 0x00D4, 0x1EA1, 0x1EF7, 0x1EEB,
-0x1EED, 0x00D9, 0x00DA, 0x1EF9, 0x1EF5, 0x00DD, 0x1EE1, 0x01B0,
-0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x1EA3, 0x0103, 0x1EEF, 0x1EAB,
-0x00E8, 0x00E9, 0x00EA, 0x1EBB, 0x00EC, 0x00ED, 0x0129, 0x1EC9,
-0x0111, 0x1EF1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x1ECF, 0x1ECD,
-0x1EE5, 0x00F9, 0x00FA, 0x0169, 0x1EE7, 0x00FD, 0x1EE3, 0x1EEE
-};
-long tab8859_10[256] =	/* from dkuug.dk:i18n/charmaps/ISO_8859-10:1993 */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0x00a0,0x0104,0x0112,0x0122,0x012a,0x0128,0x0136,0x00a7,
-0x013b,0x0110,0x0160,0x0166,0x017d,0x00ad,0x016a,0x014a,
-0x00b0,0x0105,0x0113,0x0123,0x012b,0x0129,0x0137,0x00b7,
-0x013c,0x0110,0x0161,0x0167,0x017e,0x2014,0x016b,0x014b,
-0x0100,0x00c1,0x00c2,0x00c3,0x00c4,0x00c5,0x00c6,0x012e,
-0x010c,0x00c9,0x0118,0x00cb,0x0116,0x00cd,0x00ce,0x00cf,
-0x00d0,0x0145,0x014c,0x00d3,0x00d4,0x00d5,0x00d6,0x0168,
-0x00d8,0x0172,0x00da,0x00db,0x00dc,0x00dd,0x00de,0x00df,
-0x0101,0x00e1,0x00e2,0x00e3,0x00e4,0x00e5,0x00e6,0x012f,
-0x010d,0x00e9,0x0119,0x00eb,0x0117,0x00ed,0x00ee,0x00ef,
-0x00f0,0x0146,0x014d,0x00f3,0x00f4,0x00f5,0x00f6,0x0169,
-0x00f8,0x0173,0x00fa,0x00fb,0x00fc,0x00fd,0x00fe,0x0138,
-};
-long tabMacRoman[256] =	/* (modified via world.std.com!choupt) from mduerst@ifi.unizh.ch (Martin J. Du"rst) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x00c4,0x00c5,0x00c7,0x00c9,0x00d1,0x00d6,0x00dc,0x00e1,
-0x00e0,0x00e2,0x00e4,0x00e3,0x00e5,0x00e7,0x00e9,0x00e8,
-0x00ea,0x00eb,0x00ed,0x00ec,0x00ee,0x00ef,0x00f1,0x00f3,
-0x00f2,0x00f4,0x00f6,0x00f5,0x00fa,0x00f9,0x00fb,0x00fc,
-0x2020,0x00b0,0x00a2,0x00a3,0x00a7,0x2022,0x00b6,0x00df,
-0x00ae,0x00a9,0x2122,0x00b4,0x00a8,0x2260,0x00c6,0x00d8,
-0x221e,0x00b1,0x2264,0x2265,0x00a5,0x00b5,0x2202,0x2211,
-0x220f,0x03c0,0x222b,0x00aa,0x00ba,0x2126,0x00e6,0x00f8,
-0x00bf,0x00a1,0x00ac,0x221a,0x0192,0x2248,0x2206,0x00ab,
-0x00bb,0x2026,0x00a0,0x00c0,0x00c3,0x00d5,0x0152,0x0153,
-0x2013,0x2014,0x2012,0x201d,0x2018,0x2019,0x00f7,0x25ca, /*2013 en dash suggested by Glenn A. Adams*/
-0x00ff,0x0178,0x2044,0x00a4,0x2039,0x203a,0xfb01,0xfb02,
-0x2021,0x00b7,0x201a,0x201e,0x2030,0x00c2,0x00ca,0x00c1,
-0x00cb,0x00c8,0x00cd,0x00ce,0x00cf,0x00cc,0x00d3,0x00d4,
-0xf7ff,0x00d2,0x00da,0x00db,0x00d9,0x0131,0x02c6,0x02dc,
-0x00af,0x02d8,0x02d9,0x02da,0x00b8,0x02dd,0x02db,0x02c7,
-};
-
-long tabnextstep[256] = 	/* From mduerst@ifi.unizh.ch (Martin J. Du"rst) */
-/* From NEXTSTEP Encoding Vector / Character Code Palette */
-/* quote (0027) and quoteright (2019) should be exchanged */
-/*	if visual form is considered exactly; left as is */
-/*	for compatibility with other low-end systems */
-{
-0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
-0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
-0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
-0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
-0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
-0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
-0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
-0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
-0x2007, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C7,
-0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
-0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D9,
-0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00B5, 0x00D7, 0x00F7,
-0x00A9, 0x00A1, 0x00A2, 0x00A3, 0x2044, 0x00A5, 0x0192, 0x00A7,
-0x00A4, 0x2019, 0x201C, 0x00AB, 0x2039, 0x2040, 0xFB01, 0xFB02,
-0x00AE, 0x2013, 0x2020, 0x2021, 0x00B7, 0x254E, 0x00B6, 0x2022,
-0x201A, 0x201E, 0x201D, 0x00BB, 0x2026, 0x2030, 0x00AC, 0x00BF,
-0x00B9, 0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0306, 0x0307,
-0x0308, 0x00B2, 0x030A, 0x0327, 0x00B3, 0x030B, 0x0328, 0x030C,
-0x2014, 0x00B1, 0x00BC, 0x00BD, 0x00BE, 0x00E0, 0x00E1, 0x00E2,
-0x00E3, 0x00E4, 0x00E5, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB,
-0x00EC, 0x00C6, 0x00ED, 0x00AA, 0x00EE, 0x00EF, 0x00F0, 0x00F1,
-0x0141, 0x00D8, 0x0152, 0x00BA, 0x00F2, 0x00F3, 0x00F4, 0x00F5,
-0x00F6, 0x00E6, 0x00F9, 0x00FA, 0x00FB, 0x0131, 0x00FC, 0x00FD,
-0x0142, 0x00F8, 0x0153, 0x00DF, 0x00FE, 0x00FF, 0xFFFF, 0xFFFF
-};
-
-long tabcp1250[256] = {	/* From Microsoft */
-0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
-0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
-0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
-0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
-0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
-0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
-0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
-0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
-0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
-0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
-0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
-0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
-0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
-0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
-0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
-0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021,
-0xFFFD, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
-0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
-0xFFFD, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
-0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7,
-0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
-0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
-0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
-0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
-0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
-0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
-0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
-0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
-0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
-0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
-0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9,
-};
-
-long tab8859_15[256] =		/* from anyrhine@cs.helsinki.fi (Aki Nyrhinen) */
-{
-0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
-0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
-0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
-0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
-0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
-0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
-0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
-0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
-0xa0,0xa1,0xa2,0xa3,0x20ac,0xa5,0x0160,0xa7,0x0161,0xa9,0xaa,0xab,0xac,0xad,
-0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0x017d,0xb5,0xb6,0xb7,0x017e,0xb9,0xba,0xbb,
-0x0152,0x0153,0x0178,0xbf,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,
-0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,
-0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,
-0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,
-0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
-};
-
 struct convert convert[] =
 {	/* if two entries have the same name, put the from one first */
 	{ "8859-1", "Latin-1 (Western and Northern Europe including Italian)", Table, (void *)tab8859_1 },
@@ -1046,9 +402,27 @@ struct convert convert[] =
 	{ "av", "Alternativnyj Variant", Table, (void *)tabav },
 	{ "big5", "Big 5 (HKU)", From|Func, 0, (Fnptr)big5_in },
 	{ "big5", "Big 5 (HKU)", Func, 0, (Fnptr)big5_out },
-	{ "cp866", "Microsoft Code Page 866 (Russian)", Table, (void *)tab866 },
-	{ "cp1250", "Microsoft Code Page 1250 (Central Europe)", Table, (void *)tabcp1250 },
-	{ "cp1251", "Microsoft Code Page 1251 (Cyrillic)", Table, (void *)tabcp1251 },
+	{ "cp437", "Code Page 437 (US)", Table, (void*)tabcp437 },
+	{ "cp720", "Code Page 720 (Arabic)", Table, (void*)tabcp720 },
+	{ "cp737", "Code Page 737 (Greek)", Table, (void*)tabcp737 },
+	{ "cp775", "Code Page 775 (Baltic)", Table, (void*)tabcp775 },
+	{ "cp850", "Code Page 850 (Multilingual Latin I)", Table, (void*)tabcp850 },
+	{ "cp852", "Code Page 852 (Latin II)", Table, (void*)tabcp852 },
+	{ "cp855", "Code Page 855 (Cyrillic)", Table, (void*)tabcp855 },
+	{ "cp857", "Code Page 857 (Turkish)", Table, (void*)tabcp857 },
+	{ "cp858", "Code Page 858 (Multilingual Latin I+Euro)", Table, (void*)tabcp858 },
+	{ "cp862", "Code Page 862 (Hebrew)", Table, (void*)tabcp862 },
+	{ "cp866", "Code Page 866 (Russian)", Table, (void*)tabcp866 },
+	{ "cp874", "Code Page 874 (Thai)", Table, (void*)tabcp874 },
+	{ "cp1250", "Code Page 1250 (Central Europe)", Table, (void *)tabcp1250 },
+	{ "cp1251", "Code Page 1251 (Cyrillic)", Table, (void *)tabcp1251 },
+	{ "cp1252", "Code Page 1252 (Latin I)", Table, (void *)tabcp1252 },
+	{ "cp1253", "Code Page 1253 (Greek)", Table, (void *)tabcp1253 },
+	{ "cp1254", "Code Page 1254 (Turkish)", Table, (void *)tabcp1254 },
+	{ "cp1255", "Code Page 1255 (Hebrew)", Table, (void *)tabcp1255 },
+	{ "cp1256", "Code Page 1256 (Arabic)", Table, (void *)tabcp1256 },
+	{ "cp1257", "Code Page 1257 (Baltic)", Table, (void *)tabcp1257 },
+	{ "cp1258", "Code Page 1258 (Vietnam)", Table, (void *)tabcp1258 },
 	{ "ebcdic", "EBCDIC", Table, (void *)tabebcdic },	/* 6f is recommended bad map */
 	{ "euc-k", "Korean EUC: ASCII+KS C 5601 1987", From|Func, 0, (Fnptr)uksc_in },
 	{ "euc-k", "Korean EUC: ASCII+KS C 5601 1987", Func, 0, (Fnptr)uksc_out },
@@ -1061,15 +435,15 @@ struct convert convert[] =
 	{ "jis-kanji", "ISO 2022-JP", Func, 0, (Fnptr)jisjis_out },
 	{ "koi8", "KOI-8 (GOST 19769-74)", Table, (void *)tabkoi8 },
 	{ "latin1", "ISO 8859-1", Table, (void *)tab8859_1 },
-	{ "macrom", "Macintosh Standard Roman character set", Table, (void *)tabMacRoman },
-	{ "microsoft", "microsoft", Table, (void *)microsoft },
-	{ "msdos2", "IBM PC: CP 437 with graphics in C0", Table, (void *)tabmsdos2 },
-	{ "msdos", "IBM PC: CP 437", Table, (void *)tabmsdos },
+	{ "macrom", "Macintosh Standard Roman character set", Table, (void *)tabmacroman },
+	{ "microsoft", "Windows (CP 1252)", Table, (void *)tabcp1252 },
+	{ "msdos", "IBM PC (CP 437)", Table, (void *)tabcp437 },
+	{ "msdos2", "IBM PC (CP 437 with graphics in C0)", Table, (void *)tabmsdos2 },
 	{ "ms-kanji", "Microsoft, or Shift-JIS", From|Func, 0, (Fnptr)msjis_in },
 	{ "ms-kanji", "Microsoft, or Shift-JIS", Func, 0, (Fnptr)msjis_out },
 	{ "next", "NEXTSTEP character set", Table, (void *)tabnextstep },
 	{ "ov", "Osnovnoj Variant", Table, (void *)tabov },
-	{ "ps2", "IBM PS/2: CP 850 (Multilingual)", Table, (void *)tabps2 },
+	{ "ps2", "IBM PS/2: (CP 850)", Table, (void *)tabcp850 },
 	{ "sf1", "ISO-646: Finnish/Swedish SF-1 variant", Table, (void *)tabsf1 },
 	{ "sf2", "ISO-646: Finnish/Swedish SF-2 variant (recommended)", Table, (void *)tabsf2 },
 	{ "tis", "Thai+ASCII (TIS 620-1986)", Table, (void *)tabtis620 },