Wiki-KopieMirror

Dies ist ein Mirror des Wikis von pascal.chat. Bearbeiten, Verlauf und Anmeldung finden dort statt.

Filter for Ascii and Ansi/de

Zurück zur Seite Code Beispiele.

Das Unterprogramm entfernt unerlaubte Steuerzeichen aus ASCII- und ANSI-Dateien.

pascal
uses
  FileUtil, ...;

  ...

procedure subUnerlaubteSonderzeichenEntfernen(
  const conStrQuellDatei, conStrZielDatei: string);
var
  txtQuelldatei: file of char;
  txtZieldatei: file of char;
  chrZeichen: char;

begin

  AssignFile(txtQuelldatei, UTF8ToSys(conStrQuellDatei));
  Reset(txtQuelldatei);

  AssignFile(txtZieldatei, UTF8ToSys(conStrZielDatei));
  Rewrite(txtZieldatei);
  Reset(txtZieldatei);

  while not EOF(txtQuelldatei) do
  begin

    Read(txtQuelldatei, chrZeichen);

    if (chrZeichen < #32) and (not (chrZeichen in [#9, #10, #13, #26])) then
    else
      Write(txtZieldatei, chrZeichen);

  end;

  CloseFile(txtQuelldatei);
  CloseFile(txtZieldatei);

end;

Aufruf unter Windows:

pascal

  ...

  subUnerlaubteSonderzeichenEntfernen('E:\Test.txt', 'E:\Test1.txt');
 
  ...

Aufruf unter Linux:

pascal

  ...

  subUnerlaubteSonderzeichenEntfernen('/home/user/Test.txt', '/home/user/Test1.txt') 

  ...

From the Free Pascal wiki, page "Filter for Ascii and Ansi/de", as it stood on 2020-02-15 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Version 1, zuletzt geändert von WikiArchive .