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

◆ EncodeToUtf8InPlace()

static unsafe OperationStatus System.Buffers.Text.Base64.EncodeToUtf8InPlace ( Span< byte > buffer,
int dataLength,
out int bytesWritten )
inlinestatic

Definition at line 511 of file Base64.cs.

512 {
513 if (buffer.IsEmpty)
514 {
515 bytesWritten = 0;
516 return OperationStatus.Done;
517 }
518 fixed (byte* ptr = &MemoryMarshal.GetReference(buffer))
519 {
520 int maxEncodedToUtf8Length = GetMaxEncodedToUtf8Length(dataLength);
521 if (buffer.Length >= maxEncodedToUtf8Length)
522 {
523 int num = dataLength - dataLength / 3 * 3;
524 uint num2 = (uint)(maxEncodedToUtf8Length - 4);
525 uint num3 = (uint)(dataLength - num);
526 uint num4 = 0u;
527 ref byte reference = ref MemoryMarshal.GetReference(EncodingMap);
528 if (num != 0)
529 {
530 num4 = ((num != 1) ? EncodeAndPadOne(ptr + num3, ref reference) : EncodeAndPadTwo(ptr + num3, ref reference));
531 Internal.Runtime.CompilerServices.Unsafe.WriteUnaligned(ptr + num2, num4);
532 num2 -= 4;
533 }
534 num3 -= 3;
535 while ((int)num3 >= 0)
536 {
537 num4 = Encode(ptr + num3, ref reference);
538 Internal.Runtime.CompilerServices.Unsafe.WriteUnaligned(ptr + num2, num4);
539 num2 -= 4;
540 num3 -= 3;
541 }
542 bytesWritten = maxEncodedToUtf8Length;
543 return OperationStatus.Done;
544 }
545 bytesWritten = 0;
546 return OperationStatus.DestinationTooSmall;
547 }
548 }
static unsafe uint Encode(byte *threeBytes, ref byte encodingMap)
Definition Base64.cs:627
static unsafe uint EncodeAndPadOne(byte *twoBytes, ref byte encodingMap)
Definition Base64.cs:645
static int GetMaxEncodedToUtf8Length(int length)
Definition Base64.cs:502
static ReadOnlySpan< byte > EncodingMap
Definition Base64.cs:41
static unsafe uint EncodeAndPadTwo(byte *oneByte, ref byte encodingMap)
Definition Base64.cs:661

References System.buffer, System.Buffers.Text.Base64.Encode(), System.Buffers.Text.Base64.EncodeAndPadOne(), System.Buffers.Text.Base64.EncodeAndPadTwo(), System.Buffers.Text.Base64.EncodingMap, and System.Buffers.Text.Base64.GetMaxEncodedToUtf8Length().