using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 开发辅助工具.Manager
{
class TotalCount
{
///
/// 返回字节数
///
///
///
public int GetByteLength(string s, out int HanziCount, out int engCount, out int NumCount)
{
int l = 0;
char[] q = s.ToCharArray();
HanziCount = 0;
engCount = 0;
NumCount = 0;
for (int i = 0; i < q.Length; i++)
{
int qInt = (int)q[i];
if (qInt >= 0x4E00 && qInt <= 0x9FA5) // 汉字
{
l += 2;
HanziCount++;
}
else if ((qInt >= 97 && qInt <= 122) || (qInt >= 65 && qInt <= 90)) // 英文
{
l += 1;
engCount++;
}
else if ((qInt >= 48 && qInt <= 57)) // 数字
{
l += 1;
NumCount++;
}
else
{
l += 1;
}
}
return l;
}
}
}