convert charset for console/de: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - | ||
| 1 | + | Zurück zur [[Console/de|Konsolenseite]].\ | |
| 7 | 2 | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 3 | + | =Den Zeichensatz für die Ausgabe an der Konsole anpassen= Dieser Artikel beschäftigt sich mit der Windowsprogrammierung.\ | |
| 4 | + | Falls Ihr Konsolenprogramm unter Windows Ansi-Text mit Umlauten und Sonderzeichen korrekt ausgeben soll, dann müssen Sie den Ansi-Text in den OEM-Zeichensatz konvertieren.\ | |
| 5 | + | Unter Linux (Ubuntu) ist eine Konvertierung des Zeichensatzes nicht notwendig.\ | |
| 11 | 6 | ||
| 12 | - | ||
| 7 | + | ``` pascal | |
| 13 | 8 | program project1; | |
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 9 | + | ||
| 10 | + | {$mode objfpc}{$H+} | |
| 11 | + | {$IMPLICITEXCEPTIONS OFF} | |
| 12 | + | ||
| 13 | + | uses | |
| 14 | + | Windows; | |
| 15 | + | ||
| 16 | + | var | |
| 17 | + | strText: string; | |
| 18 | + | ||
| 19 | + | // Diese Funktion übersetzt den Inhalt eines Ansistrings | |
| 20 | + | // in den Zeichensatz der Konsole | |
| 21 | + | function funAnsiZuOEM(strUebergabe: string): string; | |
| 22 | + | begin | |
| 23 | + | // Ab Lazarus 1.2.0 muss der folgende Absatz eingefügt werden: | |
| 24 | + | strUebergabe := Utf8ToAnsi(strUebergabe); | |
| 42 | 25 | ||
| 43 | - | ||
| 26 | + | // Bis Lazarus 1.0.14 genügte dieser Teil: | |
| 27 | + | strUebergabe := strUebergabe + #0; | |
| 28 | + | CharToOEM(PChar(strUebergabe), @strUebergabe[1]); | |
| 29 | + | Delete(strUebergabe, Length(strUebergabe), 1); | |
| 30 | + | Result := strUebergabe; | |
| 31 | + | end; | |
| 32 | + | ||
| 33 | + | begin | |
| 34 | + | ||
| 35 | + | strText := 'Rosé und Tölt'; | |
| 36 | + | writeln('Ausgabe: ' + funAnsiZuOEM(strText)); | |
| 37 | + | ||
| 38 | + | end. | |
| 44 | 39 | ``` | |
| 45 | 40 | ||
| 46 | 41 | --- | |
| 47 | - | ||
| 42 | + | *From the Free Pascal wiki, page "convert charset for console/de", as it stood on 2020-02-12 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).* |
