isAscii/de
Zurück zur Seite Code Beispiele.
Das Unterprogramm prüft, unabhängig vom zugrunde liegenden Betriebssystem, ob es sich um eine ASCII-Datei handelt.
uses
FileUtil, ...;
...
function isAscii(const conStrQuellDateiname: string): boolean;
var
txtQuelldatei: file of char;
chrZeichen: char;
begin
Result := False;
AssignFile(txtQuelldatei, UTF8ToSys(conStrQuellDateiname));
Reset(txtQuelldatei);
while not EOF(txtQuelldatei) do
begin
Read(txtQuelldatei, chrZeichen);
if ((chrZeichen < #32) and (not (chrZeichen in [#9, #10, #13, #26]))) or (chrZeichen > #127) then
begin
closefile(txtQuelldatei);
exit;
end;
end;
Result := True;
closefile(txtQuelldatei);
end;Aufruf unter Windows:
...
if isAscii('E:\Test.txt') = True then
...
...Aufruf unter Linux:
...
if isAscii('/home/user/Test.txt') = True then
...
...From the Free Pascal wiki, page "isAscii/de", as it stood on 2020-02-18 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.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
