Sign in Join
Wiki copytemporary

DOS2UNIX/de: what changed

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

Title: DOS2UNIX/de

OldNewLine
1+Zurück zur Seite [[Newline/de|Zeilenumbruch / Newline]].
2+
3+Das Unterprogramm konvertiert die Zeilenumbrüche einer ASCII- bzw. ANSI-Textdatei vom DOS-Format in das UNIX-Format.
4+
5+``` pascal
6+uses
7+ FileUtil, ...;
8+
9+ ...
10+
11+procedure subDos2Unix(const conStrQuellDateiname, conStrZielDateiname: string);
12+// konvertiert Zeilenumbrüche von Windows, DOS, OS/2, CP/M oder TOS (Atari) nach
13+// Unix, Linux, Android, Mac OS X, AmigaOS, BSD usw.
14+var
15+ txtQuelldatei: file of char;
16+ txtZieldatei: file of char;
17+ chrZeichen: char;
18+ booZeiger: boolean = False;
19+
20+begin
21+
22+ assignfile(txtQuelldatei, UTF8ToSys(conStrQuellDateiname));
23+ assignfile(txtZieldatei, UTF8ToSys(conStrZielDateiname));
24+ Rewrite(txtZieldatei);
25+ Reset(txtQuelldatei);
26+ Reset(txtZieldatei);
27+
28+ while not EOF(txtQuelldatei) do
29+ begin
30+
31+ Read(txtQuelldatei, chrZeichen);
32+
33+ if (chrZeichen = #13) then
34+ begin
35+ booZeiger := True;
36+ Continue;
37+ end;
38+
39+ if (chrZeichen = #10) and (booZeiger = True) then
40+ begin
41+ booZeiger := False;
42+ Write(txtZieldatei, chrZeichen);
43+ Continue;
44+ end;
45+
46+ booZeiger := False;
47+ Write(txtZieldatei, chrZeichen);
48+
49+ end;
50+
51+ closefile(txtQuelldatei);
52+ closefile(txtZieldatei);
53+
54+end;
55+```
56+
57+Aufruf unter DOS, Windows:
58+
59+``` pascal
60+ subDos2Unix('E:\Test_alt.txt', 'E:\Test_neu.txt');
61+```
62+
63+Aufruf unter Linux:
64+
65+``` pascal
66+ subDos2Unix('/home/user/Test_alt.txt', '/home/user/Test_neu.txt');
67+```
68+
69+---
70+*From the Free Pascal wiki, page "DOS2UNIX/de", as it stood on 2020-02-13 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