SysUtils.StrUpper、SysUtils.StrLower

StrUpper 和 StrLower 是转换 PChar 串的大小写的函数.

unit Unit1;



interface



uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;



type

  TForm1 = class(TForm)

    Button1: TButton;

    Button2: TButton;

    Button3: TButton;

    procedure Button1Click(Sender: TObject);

    procedure Button2Click(Sender: TObject);

    procedure Button3Click(Sender: TObject);

  end;



var

  Form1: TForm1;



implementation



{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);

const

  arr: array[0..3] of Char = 'aBcD';

begin

  StrLower(arr);

  ShowMessage(arr); {abcd}



  StrUpper(arr);

  ShowMessage(arr); {ABCD}

end;





procedure TForm1.Button2Click(Sender: TObject);

var

  p: PChar;

begin

  GetMem(p, 18);



  StrCopy(p, '万一的 Delphi 博客');



  StrLower(p);

  ShowMessage(p); {万一的 delphi 博客}



  StrUpper(p);

  ShowMessage(p); {万一的 DELPHI 博客}



  FreeMem(p);

end;





procedure TForm1.Button3Click(Sender: TObject);

var

  p,pr: PChar;

begin

  p := PChar(StringOfChar(#0, 18));



  StrCopy(p, '万一的 Delphi 博客');



  StrLower(p);

  ShowMessage(p); {万一的 delphi 博客}



  StrUpper(p);

  ShowMessage(p); {万一的 DELPHI 博客}



  StrIComp();

  StrLComp();

  StrLIComp()

end;



end.


 
   
SysUtils 单元下的公用函数目录

你可能感兴趣的:(util)