亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

c#完美截斷字符串代碼(中文+非中文)

 更新時間:2012年08月29日 00:05:42   作者:  
c#完美截斷字符串代碼(中文+非中文),需要的朋友可以參考下
復制代碼 代碼如下:

public static string Truncation(this HtmlHelper htmlHelper, string str, int len)
{
if (str == null || str.Length == 0 || len <= 0)
{
return string.Empty;
}
int l = str.Length;
#region 計算長度
int clen = 0;
while (clen < len && clen < l)
{
//每遇到一個中文,則將目標長度減一。
if ((int)str[clen] > 128) { len--; }
clen++;
}
#endregion
if (clen < l)
{
return str.Substring(0, clen) + "...";
}
else
{
return str;
}
}

相關文章

最新評論