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

◆ GetChars() [2/6]

unsafe override int System.Text.UTF7Encoding.GetChars ( byte * bytes,
int byteCount,
char * chars,
int charCount,
DecoderNLS baseDecoder )
inlinesealedpackagevirtual

Reimplemented from System.Text.Encoding.

Definition at line 591 of file UTF7Encoding.cs.

592 {
593 Decoder decoder = (Decoder)baseDecoder;
594 EncodingCharBuffer encodingCharBuffer = new EncodingCharBuffer(this, decoder, chars, charCount, bytes, byteCount);
595 int num = 0;
596 int num2 = -1;
597 bool flag = false;
598 if (decoder != null)
599 {
600 num = decoder.bits;
601 num2 = decoder.bitCount;
602 flag = decoder.firstByte;
603 }
604 if (num2 >= 16)
605 {
606 if (!encodingCharBuffer.AddChar((char)((uint)(num >> num2 - 16) & 0xFFFFu)))
607 {
608 ThrowCharsOverflow(decoder, nothingDecoded: true);
609 }
610 num2 -= 16;
611 }
612 while (encodingCharBuffer.MoreData)
613 {
614 byte nextByte = encodingCharBuffer.GetNextByte();
615 int num3;
616 if (num2 >= 0)
617 {
618 sbyte b;
619 if (nextByte < 128 && (b = _base64Values[nextByte]) >= 0)
620 {
621 flag = false;
622 num = (num << 6) | (byte)b;
623 num2 += 6;
624 if (num2 < 16)
625 {
626 continue;
627 }
628 num3 = (num >> num2 - 16) & 0xFFFF;
629 num2 -= 16;
630 }
631 else
632 {
633 num2 = -1;
634 if (nextByte != 45)
635 {
636 if (!encodingCharBuffer.Fallback(nextByte))
637 {
638 break;
639 }
640 continue;
641 }
642 if (!flag)
643 {
644 continue;
645 }
646 num3 = 43;
647 }
648 }
649 else
650 {
651 if (nextByte == 43)
652 {
653 num2 = 0;
654 flag = true;
655 continue;
656 }
657 if (nextByte >= 128)
658 {
659 if (!encodingCharBuffer.Fallback(nextByte))
660 {
661 break;
662 }
663 continue;
664 }
665 num3 = nextByte;
666 }
667 if (num3 >= 0 && !encodingCharBuffer.AddChar((char)num3))
668 {
669 if (num2 >= 0)
670 {
671 encodingCharBuffer.AdjustBytes(1);
672 num2 += 16;
673 }
674 break;
675 }
676 }
677 if (chars != null && decoder != null)
678 {
679 if (decoder.MustFlush)
680 {
681 decoder.bits = 0;
682 decoder.bitCount = -1;
683 decoder.firstByte = false;
684 }
685 else
686 {
687 decoder.bits = num;
688 decoder.bitCount = num2;
689 decoder.firstByte = flag;
690 }
691 decoder._bytesUsed = encodingCharBuffer.BytesUsed;
692 }
693 return encodingCharBuffer.Count;
694 }

References System.Text.UTF7Encoding._base64Values, System.Text.Encoding.EncodingCharBuffer.AddChar(), System.Text.Encoding.EncodingCharBuffer.AdjustBytes(), System.Text.UTF7Encoding.Decoder.bitCount, System.Text.UTF7Encoding.Decoder.bits, System.byteCount, System.bytes, System.Text.Encoding.EncodingCharBuffer.BytesUsed, System.charCount, System.chars, System.Text.Encoding.EncodingCharBuffer.Count, System.Text.Encoding.EncodingCharBuffer.Fallback(), System.Text.UTF7Encoding.Decoder.firstByte, System.Text.Encoding.EncodingCharBuffer.GetNextByte(), System.Text.Encoding.EncodingCharBuffer.MoreData, System.Text.DecoderNLS.MustFlush, and System.Text.Encoding.ThrowCharsOverflow().