목차
1. 한글 입력 automata
2. 한글 입력 automata에 대한 Program
2. 한글 입력 automata에 대한 Program
본문내용
oSungPos, JungSungPos, JongSungPos: Integer;
begin
Result := False;
ChoSungPos := Pos(Copy(String(Han3), 1 , 2), ChoSungTbl); //input을 인식한다.
JungSungPos := Pos(Copy(String(Han3), 3 , 2), JungSungTbl);
JongSungPos := Pos(Copy(String(Han3), 5 , 2), JongSungTbl);
if (ChoSungPos and JungSungPos and JongSungPos) = 0 then Exit;
ChoSung := (ChoSungPos - 1) div 2;
JungSung := (JungSungPos - 1) div 2;
JongSung := (JongSungPos - 1) div 2;
UniCode := UniCodeHangeulBase +
(ChoSung * 21 + JungSung) * 28 + JongSung; // 16진수 연산 - code 값 계산
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
@UniCode, 1, Han, 2, nil, nil); // 16진수 형태 문자를 ASCII형태로 변환하여 출력
Result := True;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
temp, temp2: string;
a, b, i: Integer;
Dest: array[0..2] of Char;
begin
a := strlen(PChar(Edit1.Text)); // input의 길이 측정
b := 1;
i := 1;
if a >= 6 then begin
RichEdit1.Text := ' ';
while b < (a / 6) + 1 do
begin
temp := Copy(String(Edit1.Text),i,6); // input을 6 byte 단위로 끊는다.
if HanCom(PChar(temp),@Dest) then begin // input을 변환
Dest[2] := Char(0);
temp2 := String(Dest); //output의 일부를 일시적으로 저장
end;
i := i + 6;
Inc(b);
RichEdit1.Text := RichEdit1.text + temp2; // output으로 출력시킨다.
end;
RichEdit1.Text := RichEdit1.Text + chr(13) + chr(10);
Edit1.Clear;
end else // 잘못된 input에 대한 error message 호출
Raise err.Create('Your Input is Wrong!'+ chr(13) + chr(10) + 'Try again');
Edit1.Clear;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
RichEdit1.Clear;
Edit1.Clear;
end;
end.
begin
Result := False;
ChoSungPos := Pos(Copy(String(Han3), 1 , 2), ChoSungTbl); //input을 인식한다.
JungSungPos := Pos(Copy(String(Han3), 3 , 2), JungSungTbl);
JongSungPos := Pos(Copy(String(Han3), 5 , 2), JongSungTbl);
if (ChoSungPos and JungSungPos and JongSungPos) = 0 then Exit;
ChoSung := (ChoSungPos - 1) div 2;
JungSung := (JungSungPos - 1) div 2;
JongSung := (JongSungPos - 1) div 2;
UniCode := UniCodeHangeulBase +
(ChoSung * 21 + JungSung) * 28 + JongSung; // 16진수 연산 - code 값 계산
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
@UniCode, 1, Han, 2, nil, nil); // 16진수 형태 문자를 ASCII형태로 변환하여 출력
Result := True;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
temp, temp2: string;
a, b, i: Integer;
Dest: array[0..2] of Char;
begin
a := strlen(PChar(Edit1.Text)); // input의 길이 측정
b := 1;
i := 1;
if a >= 6 then begin
RichEdit1.Text := ' ';
while b < (a / 6) + 1 do
begin
temp := Copy(String(Edit1.Text),i,6); // input을 6 byte 단위로 끊는다.
if HanCom(PChar(temp),@Dest) then begin // input을 변환
Dest[2] := Char(0);
temp2 := String(Dest); //output의 일부를 일시적으로 저장
end;
i := i + 6;
Inc(b);
RichEdit1.Text := RichEdit1.text + temp2; // output으로 출력시킨다.
end;
RichEdit1.Text := RichEdit1.Text + chr(13) + chr(10);
Edit1.Clear;
end else // 잘못된 input에 대한 error message 호출
Raise err.Create('Your Input is Wrong!'+ chr(13) + chr(10) + 'Try again');
Edit1.Clear;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
RichEdit1.Clear;
Edit1.Clear;
end;
end.
소개글