Пример #1
0
        public static string HtmlEncode(string value)
        {
            if (String.IsNullOrEmpty(value))
            {
                return value;
            }

            // Don't create string writer if we don't have nothing to encode
            int index = IndexOfHtmlEncodingChars(value, 0);
            if (index == -1)
            {
                return value;
            }

            LowLevelStringWriter writer = new LowLevelStringWriter();
            HtmlEncode(value, writer);
            return writer.ToString();
        }
Пример #2
0
        public static string HtmlDecode(string value)
        {
            if (String.IsNullOrEmpty(value))
            {
                return value;
            }

            // Don't create string writer if we don't have nothing to encode
            if (!StringRequiresHtmlDecoding(value))
            {
                return value;
            }

            LowLevelStringWriter writer = new LowLevelStringWriter();
            HtmlDecode(value, writer);
            return writer.ToString();
        }