본문 바로가기

Academy I/Tech Academy

[Delphi]글자가 한글인지 확인

function __han(str: string): integer;
var
  i: integer;
begin

  result := 0;  //ENG


  for i := 0 to Length(str) do begin
      if ByteType( str, i) <> mbSingleByte then begin
         result := 1;  //HAN
         break;
      end;//end if
  end;//end for

end;




function checkHangul(Msg: String): Integer;

var

  i, j: integer;

begin       

     j := 0;

     result := 0; //ENG(1 Byte)

     for i := 0 to length(Msg) - 1 do begin

         if IsDBCSLeadByte(Byte(Msg[i])) then begin

            if Msg[i] = '? then result := 0 //ENG(1 Byte)

            else Inc(j);

            

            if j > 10 then begin

               result := 1; //HAN(2 Byte)

               break;

            end;//end if

         end;//end if

     end;//end for

end;