Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ToTitleCase()

string System.Globalization.TextInfo.ToTitleCase ( string str)
inline

Definition at line 489 of file TextInfo.cs.

490 {
491 if (str == null)
492 {
493 throw new ArgumentNullException("str");
494 }
495 if (str.Length == 0)
496 {
497 return str;
498 }
499 StringBuilder result = new StringBuilder();
500 string text = null;
501 bool flag = CultureName.StartsWith("nl-", StringComparison.OrdinalIgnoreCase);
502 int num;
503 for (num = 0; num < str.Length; num++)
504 {
505 UnicodeCategory unicodeCategoryInternal = CharUnicodeInfo.GetUnicodeCategoryInternal(str, num, out var charLength);
506 if (char.CheckLetter(unicodeCategoryInternal))
507 {
508 if (flag && num < str.Length - 1 && (str[num] == 'i' || str[num] == 'I') && (str[num + 1] == 'j' || str[num + 1] == 'J'))
509 {
510 result.Append("IJ");
511 num += 2;
512 }
513 else
514 {
515 num = AddTitlecaseLetter(ref result, ref str, num, charLength) + 1;
516 }
517 int num2 = num;
518 bool flag2 = unicodeCategoryInternal == UnicodeCategory.LowercaseLetter;
519 while (num < str.Length)
520 {
521 unicodeCategoryInternal = CharUnicodeInfo.GetUnicodeCategoryInternal(str, num, out charLength);
523 {
524 if (unicodeCategoryInternal == UnicodeCategory.LowercaseLetter)
525 {
526 flag2 = true;
527 }
528 num += charLength;
529 }
530 else if (str[num] == '\'')
531 {
532 num++;
533 if (flag2)
534 {
535 if (text == null)
536 {
537 text = ToLower(str);
538 }
539 result.Append(text, num2, num - num2);
540 }
541 else
542 {
543 result.Append(str, num2, num - num2);
544 }
545 num2 = num;
546 flag2 = true;
547 }
548 else
549 {
551 {
552 break;
553 }
554 num += charLength;
555 }
556 }
557 int num3 = num - num2;
558 if (num3 > 0)
559 {
560 if (flag2)
561 {
562 if (text == null)
563 {
564 text = ToLower(str);
565 }
566 result.Append(text, num2, num3);
567 }
568 else
569 {
570 result.Append(str, num2, num3);
571 }
572 }
573 if (num < str.Length)
574 {
575 num = AddNonLetter(ref result, ref str, num, charLength);
576 }
577 }
578 else
579 {
580 num = AddNonLetter(ref result, ref str, num, charLength);
581 }
582 }
583 return result.ToString();
584 }
int AddTitlecaseLetter(ref StringBuilder result, ref string input, int inputIndex, int charLen)
Definition TextInfo.cs:600
static bool IsWordSeparator(UnicodeCategory category)
Definition TextInfo.cs:663
static bool IsLetterCategory(UnicodeCategory uc)
Definition TextInfo.cs:668
static int AddNonLetter(ref StringBuilder result, ref string input, int inputIndex, int charLen)
Definition TextInfo.cs:586
override string ToString()
StringBuilder Append(char value, int repeatCount)

References System.Globalization.TextInfo.AddNonLetter(), System.Globalization.TextInfo.AddTitlecaseLetter(), System.Text.StringBuilder.Append(), System.Globalization.TextInfo.CultureName, System.Runtime.Serialization.Dictionary, System.Globalization.CharUnicodeInfo.GetUnicodeCategoryInternal(), System.Globalization.TextInfo.IsLetterCategory(), System.Globalization.TextInfo.IsWordSeparator(), System.str, System.text, System.Globalization.TextInfo.ToLower(), and System.Text.StringBuilder.ToString().