Home » Tipps & Tricks » Object Pascal » Strings » Groß-/Kleinbuchstaben eines Strings invertieren

Groß-/Kleinbuchstaben eines Strings invertieren

Groß-/Klein-Buchstaben eines Strings invertieren kann man wie folgt machen …

function StringCaseInvert(const S: String):String;
 var
  i: Integer;
begin
  Result := S;

  for i := 1 to Length(Result) do begin
    if (Result[i] > #64) and (Result[i]  #96) and (Result[i] < #123) then
      Result[i] := UpCase(Result[i]);
  end;
end;