WikiFunctions.Summary.LimitByteLength C# (CSharp) Method

LimitByteLength() private static method

http://stackoverflow.com/questions/1225052/best-way-to-shorten-utf8-string-based-on-byte-length
private static LimitByteLength ( string input, int maxLength ) : string
input string
maxLength int
return string
        private static string LimitByteLength(string input, int maxLength)
        {
            for (int i = input.Length - 1; i >= 0; i--)
            {
                if (Encoding.UTF8.GetByteCount(input.Substring(0, i + 1)) <= maxLength)
                {
                    return input.Substring(0, i + 1);
                }
            }

            return string.Empty;
        }