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

◆ ParseFormatSpecifier()

static char System.Number.ParseFormatSpecifier ( ReadOnlySpan< char > format,
out int digits )
inlinestaticpackage

Definition at line 2657 of file Number.cs.

2658 {
2659 char c = '\0';
2660 if (format.Length > 0)
2661 {
2662 c = format[0];
2663 if ((uint)(c - 65) <= 25u || (uint)(c - 97) <= 25u)
2664 {
2665 if (format.Length == 1)
2666 {
2667 digits = -1;
2668 return c;
2669 }
2670 if (format.Length == 2)
2671 {
2672 int num = format[1] - 48;
2673 if ((uint)num < 10u)
2674 {
2675 digits = num;
2676 return c;
2677 }
2678 }
2679 else if (format.Length == 3)
2680 {
2681 int num2 = format[1] - 48;
2682 int num3 = format[2] - 48;
2683 if ((uint)num2 < 10u && (uint)num3 < 10u)
2684 {
2685 digits = num2 * 10 + num3;
2686 return c;
2687 }
2688 }
2689 int num4 = 0;
2690 int num5 = 1;
2691 while (num5 < format.Length && (uint)(format[num5] - 48) < 10u)
2692 {
2693 int num6 = num4 * 10 + format[num5++] - 48;
2694 if (num6 < num4)
2695 {
2696 throw new FormatException(SR.Argument_BadFormatSpecifier);
2697 }
2698 num4 = num6;
2699 }
2700 if (num5 == format.Length || format[num5] == '\0')
2701 {
2702 digits = num4;
2703 return c;
2704 }
2705 }
2706 }
2707 digits = -1;
2708 if (format.Length != 0 && c != 0)
2709 {
2710 return '\0';
2711 }
2712 return 'G';
2713 }

References System.SR.Argument_BadFormatSpecifier, and System.format.

Referenced by System.Number.FormatDecimal(), System.Number.FormatDouble(), System.Number.FormatHalf(), System.Number.FormatInt32(), System.Number.FormatInt64(), System.Number.FormatSingle(), System.Number.FormatUInt32(), System.Number.FormatUInt64(), System.Number.TryFormatDecimal(), System.Number.TryFormatInt32(), System.Number.TryFormatInt64(), System.Number.TryFormatUInt32(), and System.Number.TryFormatUInt64().