访问量: 29058次,访客数: 24540人,浏览量: 1次 
首页  编辑  

计算字符串中汉字和英文的字数

Tags: /超级猛料/String.字符串处理/   Date Created: Wed Aug 15 2001 04:00:43 GMT+0000 (Coordinated Universal Time)

var ans : AnsiString;

   wis : WideString;

   sub : Integer; //汉字的个数

Begin

 ans := '盗版delphi';

 wis := WideString( ans );

 sub := Length( ans ) - Length( wis );

End;

length(yourstring)-length(widestring(yourstring))=汉字个数

2*length(widestring(yourstring))-length(yourstring)=英语个数