public static string SubstringByCN(string strInput, int begin, int length)
{
if (!Regex.IsMatch(strInput, "[\u4E00-\u9FA5\uF900-\uFA2D]", RegexOptions.IgnoreCase))
{
if (strInput.Length < length)
return strInput;
else
return strInput.Substring(, length);
}
else
{
string checkstr = Regex.Replace(strInput, "[\u4E00-\u9FA5\uF900-\uFA2D]", "**", RegexOptions.IgnoreCase);
if (checkstr.Length < length)
return strInput;
else
{
string strOut = "";
int strLength = ;
for (int i = ; i < strInput.Length; i++)
{
if (strLength >= length)
break;
strOut += strInput.Substring(i, );
if (!Regex.IsMatch(strInput.Substring(i, ), "[\u4E00-\u9FA5\uF900-\uFA2D]", RegexOptions.IgnoreCase))
strLength += ;
else
strLength += ;
}
return strOut;
}
}
}