1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344:
| unit html;
interface Uses classes, sysutils; function HTMLText(s:string):string;procedure HTMLNeu(Dateiname,titel:string); procedure HTMLSchreiben(s:string); Procedure HTMLTabelle(liste:tstrings;spalten:integer);procedure HTMLzu;implementation
const HTKopf='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'+#13#10+ '"http://www.w3.org/TR/html4/loose.dtd">'+#13#10+ '<HTML>'+#13#10+'<HEAD>'; HTEnde='</BODY>'+#13#10+'</HTML>'; HTTabellenKopf='<table border="1">'+#13#10+'<tr>'; HTT_Th ='<th>'; HTT_The ='</th>'; HTT_TR ='<tr>'; HTT_TRETR ='</tr><tr>'; HTT_TD ='<td>'; HTT_TDE ='</td>'; HTT_TRTA ='</tr>'+#13#10+'</table>'; HTT_TI ='<TITLE>'; HTT_TIE ='</TITLE>'; HTT_HE ='</HEAD>';
var Datei: TextFile; Procedure HTMLTabelle(liste:tstrings;spalten:integer); var zeile,f,f1:integer; begin if liste.Count div spalten < 2 then exit; f:=0; writeln(Datei,'<table border="1">'); zeile:=liste.Count div spalten; writeln(Datei,HTT_TR); repeat writeln(datei,HTT_Th+ HTMLText(liste[f]) + HTT_The); inc(f); until f=spalten; f1:=2; repeat writeln(datei,HTT_TRETR); repeat writeln(datei,HTT_TD+ HTMLText(liste[f]) + HTT_TDE); inc(f); until f=spalten*f1; inc(f1); until f1=zeile+1; writeln(Datei,HTT_TRTA); end;
procedure HTMLNeu(Dateiname,titel:string); begin AssignFile(Datei,Dateiname+'.html'); Rewrite(Datei); WriteLn(Datei,HTKopf); WriteLn(Datei,HTT_TI+titel+HTT_TIE); WriteLn(Datei,HTT_HE); end;
procedure HTMLzu; begin WriteLn(Datei); WriteLn(Datei,HTEnde); CloseFile(Datei); end;
procedure HTMLSchreiben(s:string); begin WriteLn(Datei,s); end;
function HTMLText(s:string):string; type THTMLEntity = record html: string[8]; len : integer; end; CONST htmltab : array [32..255] of THTMLEntity = ( (html:' '; len:1), (html:'!'; len:1), (html:'"'; len:1), (html:'#'; len:1), (html:'$'; len:1), (html:'%'; len:1), (html:'&'; len:5), (html:'′'; len:8), (html:'('; len:1), (html:')'; len:1), (html:'*'; len:1), (html:'+'; len:1), (html:','; len:1), (html:'−'; len:7), (html:'.'; len:1), (html:'/'; len:1), (html:'0'; len:1), (html:'1'; len:1), (html:'2'; len:1), (html:'3'; len:1), (html:'4'; len:1), (html:'5'; len:1), (html:'6'; len:1), (html:'7'; len:1), (html:'8'; len:1), (html:'9'; len:1), (html:':'; len:1), (html:';'; len:1), (html:'<'; len:1), (html:'='; len:1), (html:'>'; len:1), (html:'?'; len:1), (html:'@'; len:1), (html:'A'; len:1), (html:'B'; len:1), (html:'C'; len:1), (html:'D'; len:1), (html:'E'; len:1), (html:'F'; len:1), (html:'G'; len:1), (html:'H'; len:1), (html:'I'; len:1), (html:'J'; len:1), (html:'K'; len:1), (html:'L'; len:1), (html:'M'; len:1), (html:'N'; len:1), (html:'O'; len:1), (html:'P'; len:1), (html:'Q'; len:1), (html:'R'; len:1), (html:'S'; len:1), (html:'T'; len:1), (html:'U'; len:1), (html:'V'; len:1), (html:'W'; len:1), (html:'X'; len:1), (html:'Y'; len:1), (html:'Z'; len:1), (html:'['; len:1), (html:'\'; len:1), (html:']'; len:1), (html:'^'; len:1), (html:'_'; len:1), (html:'`'; len:1), (html:'a'; len:1), (html:'b'; len:1), (html:'c'; len:1), (html:'d'; len:1), (html:'e'; len:1), (html:'f'; len:1), (html:'g'; len:1), (html:'h'; len:1), (html:'i'; len:1), (html:'j'; len:1), (html:'k'; len:1), (html:'l'; len:1), (html:'m'; len:1), (html:'n'; len:1), (html:'o'; len:1), (html:'p'; len:1), (html:'q'; len:1), (html:'r'; len:1), (html:'s'; len:1), (html:'t'; len:1), (html:'u'; len:1), (html:'v'; len:1), (html:'w'; len:1), (html:'x'; len:1), (html:'y'; len:1), (html:'z'; len:1), (html:'{'; len:1), (html:'|'; len:1), (html:'}'; len:1), (html:'~'; len:1), (html:''; len:1), (html:'€'; len:6), (html:''; len:1), (html:'‚'; len:1), (html:'ƒ'; len:1), (html:'„'; len:7), (html:'…'; len:1), (html:'†'; len:1), (html:'‡'; len:1), (html:'ˆ'; len:1), (html:'‰'; len:8), (html:'Š'; len:1), (html:'‹'; len:1), (html:'Œ'; len:1), (html:''; len:1), (html:'Ž'; len:1), (html:''; len:1), (html:''; len:1), (html:'‘'; len:1), (html:'’'; len:1), (html:'“'; len:1), (html:'”'; len:1), (html:'•'; len:1), (html:'–'; len:1), (html:'—'; len:1), (html:'≈'; len:7), (html:'™'; len:7), (html:'š'; len:1), (html:'›'; len:1), (html:'œ'; len:1), (html:''; len:1), (html:'ž'; len:1), (html:'Ÿ'; len:1), (html:' '; len:1), (html:'¡'; len:7), (html:'¢'; len:6), (html:'£'; len:7), (html:'¤'; len:8), (html:'¥'; len:5), (html:'¦'; len:8), (html:'§'; len:6), (html:'¨'; len:5), (html:'©'; len:6), (html:'ª'; len:6), (html:'«'; len:7), (html:'¬'; len:5), (html:''; len:1), (html:'®'; len:5), (html:'¯'; len:6), (html:'°'; len:5), (html:'±'; len:8), (html:'²'; len:6), (html:'³'; len:6), (html:'´'; len:7), (html:'µ'; len:7), (html:'¶'; len:6), (html:'·'; len:8), (html:'¸'; len:7), (html:'¹'; len:6), (html:'º'; len:1), (html:'»'; len:7), (html:'¼'; len:8), (html:'½'; len:8), (html:'¾'; len:8), (html:'¿'; len:8), (html:'À'; len:8), (html:'Á'; len:8), (html:'Â'; len:7), (html:'Ã'; len:8), (html:'Ä'; len:6), (html:'Å'; len:7), (html:'Æ'; len:7), (html:'Ç'; len:8), (html:'È'; len:8), (html:'É'; len:8), (html:'Ê'; len:7), (html:'Ë'; len:6), (html:'Ì'; len:8), (html:'Í'; len:8), (html:'Î'; len:7), (html:'Ï'; len:6), (html:'Ð'; len:5), (html:'Ñ'; len:8), (html:'Ò'; len:8), (html:'Ó'; len:8), (html:'Ô'; len:7), (html:'Õ'; len:8), (html:'Ö'; len:6), (html:'×'; len:7), (html:'Ø'; len:8), (html:'Ù'; len:8), (html:'Ú'; len:8), (html:'Û'; len:7), (html:'Ü'; len:6), (html:'Ý'; len:8), (html:'Þ'; len:6), (html:'ß'; len:7), (html:'à'; len:8), (html:'á'; len:8), (html:'â'; len:7), (html:'ã'; len:8), (html:'ä'; len:6), (html:'å'; len:7), (html:'æ'; len:7), (html:'ç'; len:8), (html:'è'; len:8), (html:'é'; len:8), (html:'ê'; len:7), (html:'ë'; len:6), (html:'ì'; len:8), (html:'í'; len:8), (html:'î'; len:7), (html:'ï'; len:6), (html:'ð'; len:5), (html:'ñ'; len:8), (html:'ò'; len:8), (html:'ó'; len:8), (html:'ô'; len:7), (html:'õ'; len:8), (html:'ö'; len:6), (html:'÷'; len:8), (html:'ø'; len:8), (html:'ù'; len:8), (html:'ú'; len:8), (html:'û'; len:7), (html:'ü'; len:6), (html:'ý'; len:8), (html:'þ'; len:7), (html:'ÿ'; len:6)); var l,cnt,lg : integer; pin, pout : pchar; begin l:=length(s); setlength(result, l*8); pout := @result[1]; pin := @s[1]; if pin=nil then exit; lg := 0; while cardinal(pin) <= cardinal(pointer(@s[l])) do begin cnt := 1; case byte(pin^) of 0..31 : pout^ := pin^; 32..255: begin cnt := htmltab[byte(pin^)].len; move(pointer(@htmltab[byte(pin^)].html[1])^, pout^, cnt); end; end; inc(pin); inc(pout, cnt); inc(lg, cnt); end; setlength(result, lg); end;
end. |