procedure TForm1.Button2Click(Sender: TObject);
var
i : integer;
s : string;
begin
s := '请问1<2吗';
for i := 1 to length(s) do
begin
if ByteType(s,i) = mbSingleByte then
ShowMessage(s + ' 的第' + inttostr(i) + '个字符是西文')
else
ShowMessage(s + ' 的第' + inttostr(i) + '个字符是中文');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i : integer;
s : WideString;
begin
s := '请问1<2吗';
for i := 1 to length(s) do
begin
if Ord(s)<=127 then
ShowMessage(s + ' 的第' + inttostr(i) + '个字符是西文')
else
ShowMessage(s + ' 的第' + inttostr(i) + '个字符是中文');
end;
end;