uffer[i]);
end;
end;
begin
tmp:=0;
if not FileExists(Edit1.text)then
begin
ShowMessage(''请你选定一个文件或你''#13#10''选择的文件不存在!'');
exit;
end;
AssignFile(F1, edit1.Text);
Reset(F1);
AssignFile(F2, edit2.Text);
Rewrite(F2);
while not Eof(F1) do
begin
alr:=0;
Read(F1, Ch1);
if not IsDBCSLeadByte(byte(ch1)) then
begin
Write(F2, Ch1);
continue;
end; //if
Read(F1, Ch11);
ch2str:= QueryCompStr(pList[ii], ch1+ch11);
if (ch2str=#0)then
begin
Write(F2, Ch1);
Write(F2, Ch11);
continue;
end;
for J:=1 to 8 do
begin
if (ch2str[j]<''6'')and (ch2str[j]>''0'') then
tmp:=strtoint(ch2str[j]);
end;
for j:=1 to 6 do
py[j]:=0;
//以下是判断加拼音的位置,注意ui和iu加声调的方式
for j:=8 downto 1 do
begin
if ch2str[j]=''a'' then py:=1;
if ch2str[j]=''o'' then py:=1;
if ch2str[j]=''e'' then py:=1;
if (ch2str[j]=''i'') and (py<>1)then py:=1;
if (ch2str[j]=''u'') and (py<>1) then py:=1;
if ch2str[j]=''ü'' then py:=1;
end;
for J:=1 to 8 do
begin
end; //if
if (ch2=''o'') and (alr=0) and (py<>1) then
begin
alr:=1;
Write(F2, pych[tmp]);
continue;
end;
if (ch2=''e'') then
begin
alr:=1; Write(F2, pych[tmp]);
continue;
end;
if (ch2=''i'')and (alr=0) and (py<>1) and (py<>1) and (py<>1) and (py=1) then
begin
alr:=1;
Write(F2, pych[tmp]);
continue;
end;
if (ch2=''u'')and (alr=0) and (py<>1) and (py<>1) and (py<>1) and (py=1) then
begin
alr:=1;
Write(F2, pych[tmp]);
continue;
end;
if (ch2=''ü'')and (alr=0)and (py<>1) then
begin
alr:=1;
Write(F2, pych[tmp]);
continue;
end;
Write(F2, Ch2);
end; //for
write(f2,'' '');
end; //while
CloseFile(F2);
CloseFile(F1);
ShowMessage(''转换完毕!'');
end;
end.
程序中判断加拼音的位置的方法有些笨拙,所幸还能用。如果你写出了更有效率的代码,希望能和大家一起分享。有一个要注意的地方,程序还不能处理多音字。另外,你可以在程序中添加进度条,以了解程序的进度。
程序在Delphi6 + Windows98下调试通过。