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

◆ EscapeString()

static unsafe char[] System.Reflection.AssemblyName.EscapeString ( string input,
int start,
int end,
char[] dest,
ref int destPos,
bool isUriString,
char force1,
char force2,
char rsvd )
inlinestaticpackage

Definition at line 429 of file AssemblyName.cs.

430 {
431 int i = start;
432 int num = start;
433 byte* ptr = stackalloc byte[160];
434 fixed (char* ptr2 = input)
435 {
436 for (; i < end; i++)
437 {
438 char c = ptr2[i];
439 if (c > '\u007f')
440 {
441 short num2 = (short)Math.Min(end - i, 39);
442 short num3 = 1;
443 while (num3 < num2 && ptr2[i + num3] > '\u007f')
444 {
445 num3++;
446 }
447 if (ptr2[i + num3 - 1] >= '\ud800' && ptr2[i + num3 - 1] <= '\udbff')
448 {
449 if (num3 == 1 || num3 == end - i)
450 {
451 throw new FormatException(SR.Arg_FormatException);
452 }
453 num3++;
454 }
455 dest = EnsureDestinationSize(ptr2, dest, i, (short)(num3 * 4 * 3), 480, ref destPos, num);
456 short num4 = (short)Encoding.UTF8.GetBytes(ptr2 + i, num3, ptr, 160);
457 if (num4 == 0)
458 {
459 throw new FormatException(SR.Arg_FormatException);
460 }
461 i += num3 - 1;
462 for (num3 = 0; num3 < num4; num3++)
463 {
465 }
466 num = i + 1;
467 }
468 else if (c == '%' && rsvd == '%')
469 {
470 dest = EnsureDestinationSize(ptr2, dest, i, 3, 120, ref destPos, num);
471 if (i + 2 < end && HexConverter.IsHexChar(ptr2[i + 1]) && HexConverter.IsHexChar(ptr2[i + 2]))
472 {
473 dest[destPos++] = '%';
474 dest[destPos++] = ptr2[i + 1];
475 dest[destPos++] = ptr2[i + 2];
476 i += 2;
477 }
478 else
479 {
481 }
482 num = i + 1;
483 }
484 else if (c == force1 || c == force2 || (c != rsvd && (isUriString ? (!IsReservedUnreservedOrHash(c)) : (!IsUnreserved(c)))))
485 {
486 dest = EnsureDestinationSize(ptr2, dest, i, 3, 120, ref destPos, num);
488 num = i + 1;
489 }
490 }
491 if (num != i && (num != start || dest != null))
492 {
493 dest = EnsureDestinationSize(ptr2, dest, i, 0, 0, ref destPos, num);
494 }
495 }
496 return dest;
497 }
static bool IsUnreserved(char c)
static void EscapeAsciiChar(char ch, char[] to, ref int pos)
static unsafe char[] EnsureDestinationSize(char *pStr, char[] dest, int currentInputPos, short charsToAdd, short minReallocateChars, ref int destPos, int prevInputPos)
static bool IsReservedUnreservedOrHash(char c)
static Encoding UTF8
Definition Encoding.cs:526

References System.SR.Arg_FormatException, System.Runtime.Serialization.Dictionary, System.Reflection.AssemblyName.EnsureDestinationSize(), System.Reflection.AssemblyName.EscapeAsciiChar(), System.input, System.HexConverter.IsHexChar(), System.Reflection.AssemblyName.IsReservedUnreservedOrHash(), System.Reflection.AssemblyName.IsUnreserved(), System.Math.Min(), System.start, and System.Text.Encoding.UTF8.

Referenced by System.Reflection.AssemblyName.EscapeCodeBase().