Difference between revisions of "isAscii/de"
From Free Pascal wiki
Jump to navigationJump to search (Created page with "{{isAscii}} <br> <br> Das Unterprogramm prüft, unabhängig vom zugrunde liegenden Betriebssystem, ob es sich um eine Ascii-Datei handelt.<br> <br> <syntaxhighlight> uses Fi...") |
m (Fixed syntax highlighting; deleted category included in page template) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{isAscii}} | {{isAscii}} | ||
− | + | ||
− | + | ||
− | Das Unterprogramm prüft, unabhängig vom zugrunde liegenden Betriebssystem, ob es sich um eine | + | Zurück zur Seite [[code examples/de|Code Beispiele]]. |
− | + | ||
− | <syntaxhighlight> | + | |
+ | Das Unterprogramm prüft, unabhängig vom zugrunde liegenden Betriebssystem, ob es sich um eine ASCII-Datei handelt. | ||
+ | |||
+ | |||
+ | <syntaxhighlight lang=pascal> | ||
uses | uses | ||
FileUtil, ...; | FileUtil, ...; | ||
Line 39: | Line 43: | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
Aufruf unter Windows: | Aufruf unter Windows: | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
... | ... | ||
Line 51: | Line 56: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
Aufruf unter Linux: | Aufruf unter Linux: | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
... | ... | ||
Line 63: | Line 69: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− |
Latest revision as of 07:27, 18 February 2020
│
Deutsch (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
...
...