WikiFunctions.Tools.WikiDecode C# (CSharp) Method

WikiDecode() public static method

Decodes URL-encoded page titles into a normal string
public static WikiDecode ( string title ) : string
title string Page title to decode
return string
        public static string WikiDecode(string title)
        {
            return HttpUtility.UrlDecode(title.Replace("+", "%2B")).Replace('_', ' ');
        }

Usage Example

Example #1
0
        // Covered by: NamespaceTests.Determine
        /// <summary>
        /// Deduces the namespace number from the input article title.
        /// </summary>
        public static int Determine(string articleTitle)
        {
            articleTitle = ColonSpace.Replace(articleTitle.Replace("%3A", ":"), ":");

            /* if there is a spacing modifying character at the start of the articletitle it will mean the article full name will never contain "Namespace:"
             * as the colon and modifier will combine to some other Unicode character, so remove any such modifier characters to allow correct derivation */
            articleTitle = SpacingModifierLetters.Replace(articleTitle, @"'");

            if (!articleTitle.Contains(":"))
            {
                return(0);
            }

            articleTitle = Tools.TurnFirstToUpper(Tools.WikiDecode(articleTitle));

            foreach (KeyValuePair <int, string> k in Variables.Namespaces)
            {
                if (articleTitle.StartsWith(k.Value))
                {
                    return(articleTitle.Length >= k.Value.Length ? k.Key : 0);
                }
            }

            foreach (KeyValuePair <int, List <string> > k in Variables.NamespaceAliases)
            {
                foreach (string s in k.Value)
                {
                    if (articleTitle.StartsWith(s))
                    {
                        return(articleTitle.Length >= s.Length ? k.Key : 0);
                    }
                }
            }

            foreach (KeyValuePair <int, string> k in Variables.CanonicalNamespaces)
            {
                if (articleTitle.StartsWith(k.Value))
                {
                    return(articleTitle.Length >= k.Value.Length ? k.Key : 0);
                }
            }

            return(0);
        }
All Usage Examples Of WikiFunctions.Tools::WikiDecode
Tools