Sign in Join
Wiki copytemporary

OEM2Ansi/de: what changed

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

Title: OEM2Ansi/de

OldNewLine
1+\
2+Zurück zur Seite [[code examples/de|Code Beispiele]].\
3+\
4+Dieser Artikel beschäftigt sich mit der Windowsprogrammierung.\
5+Das Unterprogramm konvertiert eine Datei vom OEM-Zeichensatz (DOS und Windowskonsole) in den ANSI-Zeichensatz.\
6+
7+``` pascal
8+uses
9+ Windows, FileUtil, Classes, SysUtils, ...;
10+
11+ ...
12+
13+procedure subOEM2Ansi(const conStrQuellDateiname, conStrZielDateiname: string);
14+// konvertiert eine Datei mit Ansi-Zeichensatz in den OEM-Zeichensatz
15+var
16+ txtQuelldatei: file of char;
17+ txtZieldatei: file of char;
18+ chrZeichen: char;
19+ strPuffer: string;
20+
21+begin
22+
23+ assignfile(txtQuelldatei, UTF8ToSys(conStrQuellDateiname));
24+ assignfile(txtZieldatei, UTF8ToSys(conStrZielDateiname));
25+ Rewrite(txtZieldatei);
26+ Reset(txtQuelldatei);
27+ Reset(txtZieldatei);
28+
29+ while not EOF(txtQuelldatei) do
30+ begin
31+
32+ Read(txtQuelldatei, chrZeichen);
33+ strPuffer := chrZeichen;
34+ // Übersetzt den Zeichensatz OEM in den Zeichensatz Ansi
35+ OemToCharBuff(PChar(strPuffer), PChar(strPuffer), Length(strPuffer));
36+ Write(txtZieldatei, char(strPuffer[1]));
37+
38+ end;
39+
40+ closefile(txtQuelldatei);
41+ closefile(txtZieldatei);
42+
43+end;
44+```
45+
46+\
47+Aufruf unter Windows:
48+
49+``` pascal
50+ subOEM2Ansi('E:\Test_alt.txt', 'E:\Test_neu.txt');
51+```
52+
53+---
54+*From the Free Pascal wiki, page "OEM2Ansi/de", as it stood on 2020-02-21 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