Beispiel #1
0
        /// <summary>
        /// Decodes an HTML-encoded string and returns the decoded string.
        /// </summary>
        /// <param name="s">The HTML string to decode. </param>
        /// <returns>The decoded text.</returns>
        public static string HtmlDecode(string s)
        {
#if NET_4_0
            if (s == null)
                return null;
            
            using (var sw = new StringWriter ()) {
                HttpEncoder.Current.HtmlDecode (s, sw);
                return sw.ToString ();
            }
#else
            return HttpEncoder.HtmlDecode(s);
#endif
        }
Beispiel #2
0
        /// <summary>
        /// Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.
        /// </summary>
        /// <param name="s">The HTML string to decode</param>
        /// <param name="output">The TextWriter output stream containing the decoded string. </param>
        public static void HtmlDecode(string s, TextWriter output)
        {
            if (output == null)
            {
#if NET_4_0
                throw new ArgumentNullException("output");
#else
                throw new NullReferenceException(".NET emulation");
#endif
            }

            if (!String.IsNullOrEmpty(s))
            {
#if NET_4_0
                HttpEncoder.Current.HtmlDecode(s, output);
#else
                output.Write(HttpEncoder.HtmlDecode(s));
#endif
            }
        }
Beispiel #3
0
 public static string HtmlDecode(string s) => HttpEncoder.HtmlDecode(s);
Beispiel #4
0
 public static void HtmlDecode(string s, TextWriter output) => HttpEncoder.HtmlDecode(s, output);
Beispiel #5
0
 public static string HtmlDecode(string s)
 {
     return(HttpEncoder.HtmlDecode(s));
 }