839 {
841 ISO2022Modes iSO2022Modes = ISO2022Modes.ModeASCII;
842 byte[] bytes2 = new byte[4];
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;
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();
871 {
872 default:
874 continue;
875 case ISO2022Modes.ModeInvalidEscape:
876 break;
877 case ISO2022Modes.ModeIncompleteEscape:
878 continue;
879 }
880 }
881 }
883 }
884 else
885 {
886 b = encodingCharBuffer.GetNextByte();
887 if (b == 27)
888 {
890 {
891 bytes2[0] = b;
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 {
912 {
913 if (bytes2[0] != 27)
914 {
915 num <<= 8;
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;
932 }
933 break;
934 }
935 num <<= 8;
936 num |= encodingCharBuffer.GetNextByte();
937 flag = true;
938 }
939 }
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 }
unsafe char * mapBytesToUnicode
ISO2022Modes CheckEscapeSequenceKR(byte[] bytes, int escapeCount)
byte DecrementEscapeBytes(ref byte[] bytes, ref int count)