/// <summary>
/// 从指定的字符串中取出指定的长度字符
/// </summary>
/// <param name="sub">要取长度的字符串</param>
/// <param name="len">要取多长 </param>
/// <returns>返回取得指字长度的字符串</returns>
public static string GetSub(string sub,int len)
{
int start=0;
int single=sub.Length;
char[] chars=sub.ToCharArray();
System.Text.StringBuilder sb=new System.Text.StringBuilder();
for(int i=0;i<single;i++)
{
if((int)chars[i]>255)
{
start+=2;
}
else
{
start++;
}
if(start>len)
{
break;
}
sb.Append(chars[i].ToString());
}
return sb.ToString();
}
/// 从指定的字符串中取出指定的长度字符
/// </summary>
/// <param name="sub">要取长度的字符串</param>
/// <param name="len">要取多长 </param>
/// <returns>返回取得指字长度的字符串</returns>
public static string GetSub(string sub,int len)
{
int start=0;
int single=sub.Length;
char[] chars=sub.ToCharArray();
System.Text.StringBuilder sb=new System.Text.StringBuilder();
for(int i=0;i<single;i++)
{
if((int)chars[i]>255)
{
start+=2;
}
else
{
start++;
}
if(start>len)
{
break;
}
sb.Append(chars[i].ToString());
}
return sb.ToString();
}