Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Library: Object-Pascal / Delphi-Language (https://www.delphipraxis.net/35-library-object-pascal-delphi-language/)
-   -   Delphi Ansi <-> IBMAscii (https://www.delphipraxis.net/719-ansi-ibmascii.html)

Daniel B 28. Aug 2002 16:26


Ansi <-> IBMAscii
 
Delphi-Quellcode:
function AnsiToIBMAscii(s: string): string;
var
  ii: integer;
begin
  Result := '';
  for ii := 0 to Length(s) do
  begin
    case s[ii] of
      #196: Result := Result + #142; //Ä
      #214: Result := Result + #153; //Ö
      #220: Result := Result + #154; //Ü
      #228: Result := Result + #132; //ä
      #246: Result := Result + #148; //ö
      #252: Result := Result + #129; //ü
      #223: Result := Result + #225; //ß
    else
      Result := Result + s[ii];
    end;
  end;
end;

function IBMAsciiToAnsi(s: string): string;
var
  ii: integer;
begin
  Result := '';
  for ii := 0 to Length(s) do
  begin
    case s[ii] of
      #142: Result := Result + #196; //Ä
      #153: Result := Result + #214; //Ö
      #154: Result := Result + #220; //Ü
      #132: Result := Result + #228; //ä
      #148: Result := Result + #246; //ö
      #129: Result := Result + #252; //ü
      #225: Result := Result + #223; //ß
    else
      Result := Result + s[ii];
    end;
  end;
end;
HINWEIS! //Um Eventuelle Fehler auszuschliessen

Die Schleifen gehen in diesem Beispiel von "0 to Length(s)".
Normalerweise gehen aber Schleifen von "0 to Length(s) -1" oder "1 to Length(s)", je nachdem wie man es haben will.
Das wie und was man als Variable "s" übergibt ist wichtig und dementsprechend ist die Zeile zu ändern.

Grüsse, Daniel :hi:


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:29 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz