• 查看字符串在不同编码(ASCII、Unicode、UTF7、UTF8、Default、BigEndianUnicode)下的 Hex



    IsLetter: {
    是否是个字母; 范围 A..Z a..z}
    IsUpper:  {是否是个大写字母; 范围 A..Z}
    
    IsLower:  {是否是个小写字母; 范围 a..z}
    
    IsDigit:  {是否是个十进制数字; 范围 0..9}
    
    IsNumber: {是否是个数字符号; 范围包括 0..9, 还有 ASCII 码中的 178179185188189190 }

    测试代码:


    unit Unit1;

     

    interface

     

    uses

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

      Dialogs, StdCtrls;

     

    type

      TForm1 = class(TForm)

        Button1: TButton;

        Button2: TButton;

        Button3: TButton;

        Button4: TButton;

        Button5: TButton;

        procedure Button1Click(Sender: TObject);

        procedure Button2Click(Sender: TObject);

        procedure Button3Click(Sender: TObject);

        procedure Button4Click(Sender: TObject);

        procedure Button5Click(Sender: TObject);

      end;

     

    var

      Form1: TForm1;

     

    implementation

     

    {$R *.dfm}

     

    uses Character;

     

    {IsLetter: 是否是个字母}

    procedure TForm1.Button1Click(Sender: TObject);

    var

      b1,b2,b3: Boolean;

    begin

      b1 := IsLetter('A'); {}

      b2 := IsLetter('a'); {}

      b3 := IsLetter('9'); {}

      ShowMessageFmt('%s,%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True),BoolToStr(b3,True)]);

      {True,True,False}

     

      b1 := IsLetter('D2009', 1);

      b2 := IsLetter('D2009', 2);

      ShowMessageFmt('%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True)]);

      {True,False}

    end;

     

    {IsUpper: 是否是个大写字母}

    procedure TForm1.Button2Click(Sender: TObject);

    var

      b1,b2,b3: Boolean;

    begin

      b1 := IsUpper('A'); {}

      b2 := IsUpper('a'); {}

      b3 := IsUpper('9'); {}

      ShowMessageFmt('%s,%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True),BoolToStr(b3,True)]);

      {True,False,False}

     

      b1 := IsUpper('Delphi', 1);

      b2 := IsUpper('Delphi', 2);

      ShowMessageFmt('%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True)]);

      {True,False}

    end;

     

    {IsLower: 是否是个小写字母}

    procedure TForm1.Button3Click(Sender: TObject);

    var

      b1,b2,b3: Boolean;

    begin

      b1 := IsLower('A'); {}

      b2 := IsLower('a'); {}

      b3 := IsLower('9'); {}

      ShowMessageFmt('%s,%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True),BoolToStr(b3,True)]);

      {False,True,False}

     

      b1 := IsLower('Delphi', 1);

      b2 := IsLower('Delphi', 2);

      ShowMessageFmt('%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True)]);

      {False,True}

    end;

     

    {IsDigit: 是否是个十进制数字}

    procedure TForm1.Button4Click(Sender: TObject);

    var

      b1,b2,b3: Boolean;

    begin

      b1 := IsDigit('A'); {}

      b2 := IsDigit('½'); {}

      b3 := IsDigit('9'); {}

      ShowMessageFmt('%s,%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True),BoolToStr(b3,True)]);

      {False,False,True}

     

      b1 := IsDigit('D2009', 1);

      b2 := IsDigit('D2009', 2);

      ShowMessageFmt('%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True)]);

      {False,True}

    end;

     

    {IsNumber: 是否是个数字符号}

    procedure TForm1.Button5Click(Sender: TObject);

    var

      b1,b2,b3: Boolean;

    begin

      b1 := IsNumber('A'); {}

      b2 := IsNumber('½'); {}

      b3 := IsNumber('9'); {}

      ShowMessageFmt('%s,%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True),BoolToStr(b3,True)]);

      {False,True,True}

     

      b1 := IsNumber('123¹²³¼½¾', 1);

      b2 := IsNumber('123¹²³¼½¾', 4); {这里的 9 个字符全都复合}

      ShowMessageFmt('%s,%s', [BoolToStr(b1,True),BoolToStr(b2,True)]);

      {True,True}

    end;

     

    end.

     

    
    
    
    
    
    
  • 相关阅读:
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    《C++常见问题及解答》
  • 原文地址:https://www.cnblogs.com/luckForever/p/7255192.html
Copyright © 2020-2023  润新知