Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.152 Beiträge
 
Delphi 12 Athens
 
#7

AW: Lower/UpperCase beachtet Umlaute nicht

  Alt 8. Dez 2014, 17:08
Das LowerCase (1 Parameter) ist quasi schon immer nicht auf die WinAPI losgegangen, sondern machte alles selber und auch nur für A-Z. (spontan denk ich da an eine uralte Turbo Pascal-Funktion )

Zitat:
Delphi-Quellcode:
(* ***** BEGIN LICENSE BLOCK *****
*
* The function LowerCase is licensed under the CodeGear license terms.
*
* The initial developer of the original code is Fastcode
* Code was modified to to ensure the string payload is ansi
*
* Portions created by the initial developer are Copyright (C) 2002-2004
* the initial developer. All Rights Reserved.
*
* Contributor(s): John O'Harrow, Allen Bauer
*
* ***** END LICENSE BLOCK ***** *)

function LowerCase(const S: string): string;
var
  I, Len: Integer;
  DstP, SrcP: PChar;
  Ch: Char;
begin
  Len := Length(S);
  SetLength(Result, Len);
  if Len > 0 then
  begin
    DstP := PChar(Pointer(Result));
    SrcP := PChar(Pointer(S));
    for I := Len downto 1 do
    begin
      Ch := SrcP^;
      case Ch of
        'A'..'Z':
          Ch := Char(Word(Ch) or $0020);
      end;
      DstP^ := Ch;
      Inc(DstP);
      Inc(SrcP);
    end;
  end;
end;

function LowerCase(const S: string; LocaleOptions: TLocaleOptions): string;
begin
  if LocaleOptions = loUserLocale then
    Result := AnsiLowerCase(S)
  else
    Result := LowerCase(S);
end;
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat