public static string GetString(string str, int length )
        {
            int i = 0, j = 0;
            foreach (char chr in str)
            {
                if ((int)chr >30)
                {
                    i += 2;
                }
                else
                {
                    i++;
                }
                if (i > length)
                {
                    str = str.Substring(0, j) + "...";
                    break;
                }
                j++;
            }
            return str;

        }
        #endregion

posted on 2007-12-25 08:42  风语战士  阅读(236)  评论(0编辑  收藏  举报