strEnglishSign:string = ',./<>?''";:]}[{/|=+-_)(*&^%$#@!~`';
strNumberSign:string = '0123456789';
strCharSign:string= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
procedure TMDIChild.CheckFileInfo;
var
BlankNumber,ChineseCharNumber,EnglishCharNumber,
EnglishSignNumber,NumberCharNumber,OtherCharNumber:integer;
s :string;
i:integer;
begin
BlankNumber := 0;
ChineseCharNumber := 0;
EnglishCharNumber := 0;
EnglishSignNumber := 0;
NumberCharNumber := 0;
OtherCharNumber := 0;
s := Editor.Text;//Editor是TRichEdit
for i := 1 to Length(s) do
begin
if(s = ' ') then Inc(BlankNumber)
else if(integer(s) > $80) then Inc(ChineseCharNumber)
else if(Pos(s,strEnglishSign) <> 0) then Inc(EnglishSignNumber)
else if(Pos(s,strCharSign) <> 0) then Inc(EnglishCharNumber)
else if(Pos(s,strNumberSign) <> 0) then Inc(NumberCharNumber)
else Inc(OtherCharNumber);
end;
ShowMessage('中文(连中文标点符号):'+ IntToStr(ChineseCharNumber div 2)+#13#10
+ '数字字符:'+IntToStr(NumberCharNumber)+#13#10
+ '空格:'+IntToStr(BlankNumber)+#13#10
+ '英文字符:'+IntToStr(EnglishCharNumber)+#13#10
+ '英文标点:'+IntToStr(EnglishSignNumber)+#13#10
+ '不可见字符(回车、换行等):'+IntToStr(OtherCharNumber));
end;
够详细了吧。