public static class HtmlHelpers
{
public static string Truncate(this HtmlHelper helper, string inputString, int length)
{
string tempString = string.Empty;
for (int i = 0, tempIndex = 0; i < inputString.Length; ++i, ++tempIndex)
{
if (System.Text.Encoding.UTF8.GetBytes(new char[] { inputString[i] }).Length > 1)
{
++tempIndex;
}
if (tempIndex >= length)
{
tempString += "...";
break;
}
tempString += inputString[i];
}
return tempString;
}
}