WikiFunctions.Tools.CleanSortKey C# (CSharp) Method

CleanSortKey() public static method

Cleans sortkeys: removes diacritics, except for ru, fr, pl wikis Cleans up/removes specific characters per WP:SORTKEY
public static CleanSortKey ( string defaultsort ) : string
defaultsort string
return string
        public static string CleanSortKey(string defaultsort)
        {
            // no diacritic removal in sortkeys on wikis using uca- / Unicode sorting (e.g. fr/pl/ru wiki)
            if (!Variables.UnicodeCategoryCollation)
                defaultsort = RemoveDiacritics(defaultsort);

            defaultsort = defaultsort.Replace("–", "–");
            defaultsort = defaultsort.Replace("—", "—");

            // normalisation - simplify double spaces to a single one
            while(defaultsort.Contains("  "))
                defaultsort = defaultsort.Replace("  ", " ");

            foreach (var p in SortKeyChars)
            {
                defaultsort = defaultsort.Replace(p[0], p[1]);
            }

            return defaultsort;
        }
Tools