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

◆ UrlEncode() [1/2]

static byte[] System.Web.Util.HttpEncoder.UrlEncode ( byte[] bytes,
int offset,
int count )
inlinestaticprivate

Definition at line 461 of file HttpEncoder.cs.

462 {
464 {
465 return null;
466 }
467 int num = 0;
468 int num2 = 0;
469 for (int i = 0; i < count; i++)
470 {
471 char c = (char)bytes[offset + i];
472 if (c == ' ')
473 {
474 num++;
475 }
476 else if (!HttpEncoderUtility.IsUrlSafeChar(c))
477 {
478 num2++;
479 }
480 }
481 if (num == 0 && num2 == 0)
482 {
483 if (offset == 0 && bytes.Length == count)
484 {
485 return bytes;
486 }
487 byte[] array = new byte[count];
488 Buffer.BlockCopy(bytes, offset, array, 0, count);
489 return array;
490 }
491 byte[] array2 = new byte[count + num2 * 2];
492 int num3 = 0;
493 for (int j = 0; j < count; j++)
494 {
495 byte b = bytes[offset + j];
496 char c2 = (char)b;
497 if (HttpEncoderUtility.IsUrlSafeChar(c2))
498 {
499 array2[num3++] = b;
500 continue;
501 }
502 if (c2 == ' ')
503 {
504 array2[num3++] = 43;
505 continue;
506 }
507 array2[num3++] = 37;
508 array2[num3++] = (byte)System.HexConverter.ToCharLower(b >> 4);
509 array2[num3++] = (byte)System.HexConverter.ToCharLower(b);
510 }
511 return array2;
512 }
static char ToCharLower(int value)
static bool ValidateUrlEncodingParameters([NotNullWhen(true)] byte[] bytes, int offset, int count)

References System.array, System.Buffer.BlockCopy(), System.bytes, System.count, System.Web.Util.HttpEncoderUtility.IsUrlSafeChar(), System.offset, System.HexConverter.ToCharLower(), and System.Web.Util.HttpEncoder.ValidateUrlEncodingParameters().