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

◆ TryEncodeToUtf8() [1/2]

static bool System.Text.Rune.TryEncodeToUtf8 ( Rune value,
Span< byte > destination,
out int bytesWritten )
inlinestaticprivate

Definition at line 585 of file Rune.cs.

586 {
587 if (!destination.IsEmpty)
588 {
589 if (value.IsAscii)
590 {
591 destination[0] = (byte)value._value;
592 bytesWritten = 1;
593 return true;
594 }
595 if (1u < (uint)destination.Length)
596 {
597 if ((long)value.Value <= 2047L)
598 {
599 destination[0] = (byte)(value._value + 12288 >> 6);
600 destination[1] = (byte)((value._value & 0x3F) + 128);
601 bytesWritten = 2;
602 return true;
603 }
604 if (2u < (uint)destination.Length)
605 {
606 if ((long)value.Value <= 65535L)
607 {
608 destination[0] = (byte)(value._value + 917504 >> 12);
609 destination[1] = (byte)(((value._value & 0xFC0) >> 6) + 128);
610 destination[2] = (byte)((value._value & 0x3F) + 128);
611 bytesWritten = 3;
612 return true;
613 }
614 if (3u < (uint)destination.Length)
615 {
616 destination[0] = (byte)(value._value + 62914560 >> 18);
617 destination[1] = (byte)(((value._value & 0x3F000) >> 12) + 128);
618 destination[2] = (byte)(((value._value & 0xFC0) >> 6) + 128);
619 destination[3] = (byte)((value._value & 0x3F) + 128);
620 bytesWritten = 4;
621 return true;
622 }
623 }
624 }
625 }
626 bytesWritten = 0;
627 return false;
628 }

References System.destination, System.L, and System.value.