Ejemplo n.º 1
0
        public static string GetCharset(string htmlDoc)
        {
            if (htmlDoc == null)
            {
                return(null);
            }

            // First try to get the charset from Meta tag, then try the XML/XHTML approach.
            string charset = HtmlTagExtract.GetMetaCharset(htmlDoc);

            if (charset == null)
            {
                charset = HtmlTagExtract.GetXmlCharset(htmlDoc);
            }

            return(charset);
        }
Ejemplo n.º 2
0
        static bool TryGetMetaRefresh(WebString page, out Uri refreshUrl)
        {
            string metaRefresh = HtmlTagExtract.GetMetaRefresh(page.Document);

            if (metaRefresh != null)
            {
                // Relative refresh URL.
                // Try this one first, because creating an absolute URL out of a relative one starting with a '/' can
                // lead to it being interpreted as a file:/// URI.
                if (Uri.TryCreate(page.Location, metaRefresh, out refreshUrl))
                {
                    return(true);
                }
                // Absolute refresh URL.
                if (Uri.TryCreate(metaRefresh, UriKind.Absolute, out refreshUrl))
                {
                    return(true);
                }
            }

            refreshUrl = null;
            return(false);
        }