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

◆ GetCharsCP50225KR()

unsafe int System.Text.ISO2022Encoding.GetCharsCP50225KR ( byte * bytes,
int byteCount,
char * chars,
int charCount,
ISO2022Decoder decoder )
inlineprivate

Definition at line 838 of file ISO2022Encoding.cs.

839 {
840 EncodingCharBuffer encodingCharBuffer = new EncodingCharBuffer(this, decoder, chars, charCount, bytes, byteCount);
841 ISO2022Modes iSO2022Modes = ISO2022Modes.ModeASCII;
842 byte[] bytes2 = new byte[4];
843 int count = 0;
844 if (decoder != null)
845 {
846 iSO2022Modes = decoder.currentMode;
847 count = decoder.bytesLeftOverCount;
848 for (int i = 0; i < count; i++)
849 {
850 bytes2[i] = decoder.bytesLeftOver[i];
851 }
852 }
853 while (encodingCharBuffer.MoreData || count > 0)
854 {
855 byte b;
856 if (count > 0)
857 {
858 if (bytes2[0] == 27)
859 {
860 if (!encodingCharBuffer.MoreData)
861 {
862 if (decoder != null && !decoder.MustFlush)
863 {
864 break;
865 }
866 }
867 else
868 {
869 bytes2[count++] = encodingCharBuffer.GetNextByte();
870 switch (CheckEscapeSequenceKR(bytes2, count))
871 {
872 default:
873 count = 0;
874 continue;
875 case ISO2022Modes.ModeInvalidEscape:
876 break;
877 case ISO2022Modes.ModeIncompleteEscape:
878 continue;
879 }
880 }
881 }
882 b = DecrementEscapeBytes(ref bytes2, ref count);
883 }
884 else
885 {
886 b = encodingCharBuffer.GetNextByte();
887 if (b == 27)
888 {
889 if (count == 0)
890 {
891 bytes2[0] = b;
892 count = 1;
893 continue;
894 }
895 encodingCharBuffer.AdjustBytes(-1);
896 }
897 }
898 switch (b)
899 {
900 case 14:
901 iSO2022Modes = ISO2022Modes.ModeKR;
902 continue;
903 case 15:
904 iSO2022Modes = ISO2022Modes.ModeASCII;
905 continue;
906 }
907 ushort num = b;
908 bool flag = false;
909 if (iSO2022Modes == ISO2022Modes.ModeKR && b != 32 && b != 9 && b != 10)
910 {
911 if (count > 0)
912 {
913 if (bytes2[0] != 27)
914 {
915 num <<= 8;
916 num |= DecrementEscapeBytes(ref bytes2, ref count);
917 flag = true;
918 }
919 }
920 else
921 {
922 if (!encodingCharBuffer.MoreData)
923 {
924 if (decoder == null || decoder.MustFlush)
925 {
926 encodingCharBuffer.Fallback(b);
927 }
928 else if (chars != null)
929 {
930 bytes2[0] = b;
931 count = 1;
932 }
933 break;
934 }
935 num <<= 8;
936 num |= encodingCharBuffer.GetNextByte();
937 flag = true;
938 }
939 }
940 char c = mapBytesToUnicode[(int)num];
941 if (c == '\0' && num != 0)
942 {
943 if (flag)
944 {
945 if (!encodingCharBuffer.Fallback((byte)(num >> 8), (byte)num))
946 {
947 break;
948 }
949 }
950 else if (!encodingCharBuffer.Fallback(b))
951 {
952 break;
953 }
954 }
955 else if (!encodingCharBuffer.AddChar(c, (!flag) ? 1 : 2))
956 {
957 break;
958 }
959 }
960 if (chars != null && decoder != null)
961 {
962 if (!decoder.MustFlush || count != 0)
963 {
964 decoder.currentMode = iSO2022Modes;
965 decoder.bytesLeftOverCount = count;
966 decoder.bytesLeftOver = bytes2;
967 }
968 else
969 {
970 decoder.currentMode = ISO2022Modes.ModeASCII;
971 decoder.shiftInOutMode = ISO2022Modes.ModeASCII;
972 decoder.bytesLeftOverCount = 0;
973 }
974 decoder.m_bytesUsed = encodingCharBuffer.BytesUsed;
975 }
976 return encodingCharBuffer.Count;
977 }
ISO2022Modes CheckEscapeSequenceKR(byte[] bytes, int escapeCount)
byte DecrementEscapeBytes(ref byte[] bytes, ref int count)

References System.Text.Encoding.EncodingCharBuffer.AddChar(), System.Text.Encoding.EncodingCharBuffer.AdjustBytes(), System.byteCount, System.bytes, System.Text.ISO2022Encoding.ISO2022Decoder.bytesLeftOver, System.Text.ISO2022Encoding.ISO2022Decoder.bytesLeftOverCount, System.Text.Encoding.EncodingCharBuffer.BytesUsed, System.charCount, System.chars, System.Text.ISO2022Encoding.CheckEscapeSequenceKR(), System.count, System.Text.Encoding.EncodingCharBuffer.Count, System.Text.ISO2022Encoding.ISO2022Decoder.currentMode, System.Text.ISO2022Encoding.DecrementEscapeBytes(), System.Text.Encoding.EncodingCharBuffer.Fallback(), System.Text.Encoding.EncodingCharBuffer.GetNextByte(), System.Text.DBCSCodePageEncoding.mapBytesToUnicode, System.Text.Encoding.EncodingCharBuffer.MoreData, and System.Text.DecoderNLS.MustFlush.

Referenced by System.Text.ISO2022Encoding.GetChars().