获得字符串长度
/// <summary>
/// 获得字符串长度
/// </summary>
/// <param name="str">要获得长度的字符串</param>
/// <returns></returns>
public static int GetLengthOfStr(string str)
{
int lenTotal = 0;
int n = str.Length;
string strWord = "";
int asc;
for (int i = 0; i < n; i++)
{
strWord = str.Substring(i, 1);
asc = Convert.ToChar(strWord);
if (asc < 0 || asc > 127)
lenTotal = lenTotal + 3;
else
lenTotal = lenTotal + 1;
}
return lenTotal;
}