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

◆ UrlEncode()

static ? string System.Net.WebUtility.UrlEncode ( string? value)
inlinestatic

Definition at line 678 of file WebUtility.cs.

679 {
680 if (string.IsNullOrEmpty(value))
681 {
682 return value;
683 }
684 int num = 0;
685 int num2 = 0;
686 foreach (char c in value)
687 {
688 if (IsUrlSafeChar(c))
689 {
690 num++;
691 }
692 else if (c == ' ')
693 {
694 num2++;
695 }
696 }
697 int num3 = num + num2;
698 if (num3 == value.Length)
699 {
700 if (num2 != 0)
701 {
702 return value.Replace(' ', '+');
703 }
704 return value;
705 }
706 int byteCount = Encoding.UTF8.GetByteCount(value);
707 int num4 = byteCount - num3;
708 int num5 = num4 * 2;
709 byte[] array = new byte[byteCount + num5];
710 Encoding.UTF8.GetBytes(value, 0, value.Length, array, num5);
712 return Encoding.UTF8.GetString(array);
713 }
static void GetEncodedBytes(byte[] originalBytes, int offset, int count, byte[] expandedBytes)
static bool IsUrlSafeChar(char ch)
static Encoding UTF8
Definition Encoding.cs:526

References System.array, System.byteCount, System.Net.WebUtility.GetEncodedBytes(), System.Net.WebUtility.IsUrlSafeChar(), System.Text.Encoding.UTF8, and System.value.

Referenced by System.Diagnostics.DistributedContextPropagator.InjectBaggage().