unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//利用 StrByteType 做了个函数:
function GetByteType(p: PChar; i: Integer): string;
var
bt: TMbcsByteType;
begin
bt := StrByteType(p, i);
case bt of
mbSingleByte : Result := 'SingleByte'; {ASCII 字符}
mbLeadByte : Result := 'LeadByte'; {双字节字符前半}
mbTrailByte : Result := 'TrailByte'; {双字节字符后半}
end;
end;
//测试:
procedure TForm1.FormCreate(Sender: TObject);
var
p: PChar;
i: Integer;
begin
p := 'abc万一123';
for i := 0 to Length(p) - 1 do
Memo1.Lines.Add(GetByteType(p, i));
{显示结果如下:
SingleByte
SingleByte
SingleByte
LeadByte
TrailByte
LeadByte
TrailByte
SingleByte
SingleByte
SingleByte
}
end;
end.
SysUtils 单元下的公用函数目录