반응형

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function IsDigit(ch: Char): Boolean;
begin
  Result := ch in ['0'..'9'];
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  s1, s2: String;
  i: integer;
begin
  s1 := Edit1.text;

  for i:=1 to length(s1) do
  begin
    s2 := '';

    if IsCharAlphaNumeric(s1[i]) then
    begin
      s2 := s2 + '<영문 or 숫자>';

      if IsDigit(s1[i]) then
        s2 := s2 + '<숫자>'
      else if IsCharAlpha(s1[i]) then
      begin
        s2 := s2 + '<영문>';
        if IsCharLower(s1[i]) then
          s2 := s2 + '<소문자>'
        else if IsCharUpper(s1[i]) then
          s2 := s2 + '<대문자>'
      end;
    end
    else if IsDBCSLeadByte(Byte(s1[i])) then
    begin
      // IsDBCSLeadByte()는 double byte character set(DBCS) 의 lead byte인지 검사합니다
      s2 := s2 + '<한글 or 한문>';
    end;
    
    Memo1.Lines.Add(s1[i]+' = '+s2);
  end;  
end;

end.

반응형
반응형