Tag: counting

字符数减去HTML字符C#

我试图找出一种方法来计算字符串中的字符数,截断字符串,然后返回它。 但是,我需要此函数来不计算HTML标记。 问题是,如果它计算HTML标记,那么如果截断点位于标记的中间,那么页面将显示为已损坏。 这就是我到目前为止…… public string Truncate(string input, int characterLimit, string currID) { string output = input; // Check if the string is longer than the allowed amount // otherwise do nothing if (output.Length > characterLimit && characterLimit > 0) { // cut the string down to the maximum number of characters output = output.Substring(0, […]