Difference between revisions of "isAscii/de"
From Free Pascal wiki
Jump to navigationJump to searchm |
m (consistant naming) |
||
Line 2: | Line 2: | ||
<br> | <br> | ||
<br> | <br> | ||
− | Das Unterprogramm prüft, unabhängig vom zugrunde liegenden Betriebssystem, ob es sich um eine | + | Das Unterprogramm prüft, unabhängig vom zugrunde liegenden Betriebssystem, ob es sich um eine ASCII-Datei handelt.<br> |
<br> | <br> | ||
<syntaxhighlight> | <syntaxhighlight> |
Revision as of 18:07, 5 September 2013
│
Deutsch (de) │
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
...
...
--Olaf 07:43, 27 August 2013 (CEST)