WikiFunctions.Tools.TurnFirstToUpper C# (CSharp) Method

TurnFirstToUpper() public static method

Returns version of the string with first character in upper case but not on wiktionary
public static TurnFirstToUpper ( string input ) : string
input string
return string
        public static string TurnFirstToUpper(string input)
        {
            if (!Variables.CapitalizeFirstLetter|| string.IsNullOrEmpty(input))
                return input;

            return TurnFirstToUpperNoProjectCheck(input);
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Returns Category key from article name e.g. "David Smith" returns "Smith, David".
        /// special case: "John Doe, Jr." turns into "Doe, Jonn Jr."
        /// http://en.wikipedia.org/wiki/Wikipedia:Categorization_of_people
        /// </summary>
        public static string MakeHumanCatKey(string Name)
        {
            Name = RemoveNamespaceString(Regex.Replace(RemoveDiacritics(Name), @"\(.*?\)$", "").Replace("'", "").Trim()).Trim();
            string origName = Name;

            if (!Name.Contains(" ") || Variables.LangCode == LangCodeEnum.uk)
            {
                return(origName);
            }
            // ukwiki uses "Lastname Firstname Patronymic" convention, nothing more is needed

            string suffix = "";
            int    pos    = Name.IndexOf(',');

            // ruwiki has "Lastname, Firstname Patronymic" convention
            if (pos >= 0 && Variables.LangCode != LangCodeEnum.ru)
            {
                suffix = Name.Substring(pos + 1).Trim();
                Name   = Name.Substring(0, pos).Trim();
            }

            int    intLast  = Name.LastIndexOf(" ") + 1;
            string lastName = Name.Substring(intLast).Trim();

            Name = Name.Remove(intLast).Trim();
            if (IsRomanNumber(lastName))
            {
                if (Name.Contains(" "))
                {
                    suffix  += lastName;
                    intLast  = Name.LastIndexOf(" ") + 1;
                    lastName = Name.Substring(intLast);
                    Name     = Name.Remove(intLast).Trim();
                }
                else
                { //if (Suffix != "") {
                    // We have something like "Peter" "II" "King of Spain" (first/last/suffix), so return what we started with
                    // OR We have "Fred" "II", we don't want to return "II, Fred" so we must return "Fred II"
                    return(origName);
                }
            }
            lastName = Tools.TurnFirstToUpper(lastName.ToLower());

            Name = (lastName + ", " + Name + ", " + suffix).Trim(" ,".ToCharArray());

            return(Name);
        }
All Usage Examples Of WikiFunctions.Tools::TurnFirstToUpper
Tools