Delphi统计字数(汉字+字母+符号)


本文整理自网络,侵删。

 根据asc码分别进行统计,看有多少字母和符号,汉字分开统计,一个汉字算计数1

function TFrm_main.MsgCounter(str: string): string;
var
s:string; //保存字符串
i,e,c:integer;//保存变量
begin
s:=str;
e:=0;c:=0;
for i:=1 to length(s) do
begin
if (ord(s[i])>=33)and(ord(s[i])<=126) then
//判断字符的顺序号
begin
inc(e);
end
else
if (ord(s[i])>=127) then
//判断字符的顺序号
begin
inc(c);
end;
end;

Result:=IntToStr(e+(c div 2));
end;


文章来源于: http://www.samool.com/archives/41374/

相关阅读 >>

Delphi 用 directshow 获取本机的视频摄像设备列表

Delphi中调用必应搜索(bing)的api函数

Delphi system.messaging.pas例子

Delphi 读取正在被占用的txt文件

indy10下的tidhttp控件获取源码乱码的解决方法

Delphi sysutils.lastdelimiter - 判断一个字符串在另一个字符串中最后出现的位置

Delphi 取得某一天所在的星期一及星期天

Delphi 在xp/2k 下实现 win+ctrl+del 等键的屏蔽的方法

Delphi getfilehashmd5

Delphi 的异步方法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...