#region
breakString:获取指定长度的字符,一个中文算两个字符.
/// <summary>
/// 获取指定长度的字符,一个中文算两个字符.
/// </summary>
/// <param name="S">要获取字符的原始字符串.</param>
/// <param name="strLen">指定的长度,中文*2.</param>
/// <returns></returns>
public static string breakString(string S, int strLen)
{
string qdkRe = "";
if (S == null || S == "")
{
return qdkRe;
}
qdkRe = S;
int sLen, tLen, cLen;
sLen = S.Length;
tLen = 0;
for (int i = 0; i < sLen; i++)
{
cLen = S[i];
if (cLen > 255)
{
tLen += 2;
}
else
{
tLen += 1;
}
if (tLen >= strLen)
{
qdkRe = S.Substring(0, i);
qdkRe += "...";
break;
}
}
}