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

◆ GetChars() [4/7]

unsafe int System.Text.Base64Encoding.GetChars ( byte[] bytes,
int byteIndex,
int byteCount,
byte[] chars,
int charIndex )
inline

Definition at line 399 of file Base64Encoding.cs.

400 {
401 if (bytes == null)
402 {
403 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("bytes"));
404 }
405 if (byteIndex < 0)
406 {
407 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteIndex", System.SR.ValueMustBeNonNegative));
408 }
409 if (byteIndex > bytes.Length)
410 {
411 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, bytes.Length)));
412 }
413 if (byteCount < 0)
414 {
415 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteCount", System.SR.ValueMustBeNonNegative));
416 }
417 if (byteCount > bytes.Length - byteIndex)
418 {
419 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteCount", System.SR.Format(System.SR.SizeExceedsRemainingBufferSpace, bytes.Length - byteIndex)));
420 }
422 if (chars == null)
423 {
424 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars"));
425 }
426 if (charIndex < 0)
427 {
428 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charIndex", System.SR.ValueMustBeNonNegative));
429 }
430 if (charIndex > chars.Length)
431 {
432 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, chars.Length)));
433 }
435 {
437 }
438 if (byteCount > 0)
439 {
440 fixed (byte* ptr6 = &Val2byte[0])
441 {
442 fixed (byte* ptr = &bytes[byteIndex])
443 {
444 fixed (byte* ptr4 = &chars[charIndex])
445 {
446 byte* ptr2 = ptr;
447 byte* ptr3 = ptr2 + byteCount - 3;
448 byte* ptr5 = ptr4;
449 while (ptr2 <= ptr3)
450 {
451 *ptr5 = ptr6[*ptr2 >> 2];
452 ptr5[1] = ptr6[((*ptr2 & 3) << 4) | (ptr2[1] >> 4)];
453 ptr5[2] = ptr6[((ptr2[1] & 0xF) << 2) | (ptr2[2] >> 6)];
454 ptr5[3] = ptr6[ptr2[2] & 0x3F];
455 ptr2 += 3;
456 ptr5 += 4;
457 }
458 if (ptr2 - ptr3 == 2)
459 {
460 *ptr5 = ptr6[*ptr2 >> 2];
461 ptr5[1] = ptr6[(*ptr2 & 3) << 4];
462 ptr5[2] = 61;
463 ptr5[3] = 61;
464 }
465 else if (ptr2 - ptr3 == 1)
466 {
467 *ptr5 = ptr6[*ptr2 >> 2];
468 ptr5[1] = ptr6[((*ptr2 & 3) << 4) | (ptr2[1] >> 4)];
469 ptr5[2] = ptr6[(ptr2[1] & 0xF) << 2];
470 ptr5[3] = 61;
471 }
472 }
473 }
474 }
475 }
476 return charCount;
477 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ValueMustBeNonNegative
Definition SR.cs:296
static string SizeExceedsRemainingBufferSpace
Definition SR.cs:324
static string OffsetExceedsBufferSize
Definition SR.cs:322
static string XmlArrayTooSmall
Definition SR.cs:348
Definition SR.cs:7
override int GetCharCount(byte[] bytes, int index, int count)
static ReadOnlySpan< byte > Val2byte

References System.byteCount, System.byteIndex, System.bytes, System.charCount, System.charIndex, System.chars, System.Runtime.Serialization.Dictionary, System.SR.Format(), System.Text.Base64Encoding.GetCharCount(), System.SR.OffsetExceedsBufferSize, System.SR.SizeExceedsRemainingBufferSpace, System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(), System.Text.Base64Encoding.Val2byte, System.SR.ValueMustBeNonNegative, and System.SR.XmlArrayTooSmall.