Sign in Join
Wiki copytemporary

isAscii/de: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: isAscii/de

OldNewLine
1+Zurück zur Seite [[code examples/de|Code Beispiele]].
2+
3+Das Unterprogramm prüft, unabhängig vom zugrunde liegenden Betriebssystem, ob es sich um eine ASCII-Datei handelt.
4+
5+``` pascal
6+uses
7+ FileUtil, ...;
8+
9+ ...
10+
11+function isAscii(const conStrQuellDateiname: string): boolean;
12+var
13+ txtQuelldatei: file of char;
14+ chrZeichen: char;
15+
16+begin
17+
18+ Result := False;
19+ AssignFile(txtQuelldatei, UTF8ToSys(conStrQuellDateiname));
20+ Reset(txtQuelldatei);
21+
22+ while not EOF(txtQuelldatei) do
23+ begin
24+
25+ Read(txtQuelldatei, chrZeichen);
26+
27+ if ((chrZeichen < #32) and (not (chrZeichen in [#9, #10, #13, #26]))) or (chrZeichen > #127) then
28+ begin
29+ closefile(txtQuelldatei);
30+ exit;
31+ end;
32+
33+ end;
34+
35+ Result := True;
36+ closefile(txtQuelldatei);
37+
38+end;
39+```
40+
41+Aufruf unter Windows:
42+
43+``` pascal
44+
45+ ...
46+
47+ if isAscii('E:\Test.txt') = True then
48+ ...
49+
50+ ...
51+```
52+
53+Aufruf unter Linux:
54+
55+``` pascal
56+
57+ ...
58+
59+ if isAscii('/home/user/Test.txt') = True then
60+ ...
61+
62+ ...
63+```
64+
65+---
66+*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](/wiki-contact).*

Back to history