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

◆ GetCharsCP52936()

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

Definition at line 996 of file ISO2022Encoding.cs.

997 {
998 EncodingCharBuffer encodingCharBuffer = new EncodingCharBuffer(this, decoder, chars, charCount, bytes, byteCount);
999 ISO2022Modes iSO2022Modes = ISO2022Modes.ModeASCII;
1000 int num = -1;
1001 bool flag = false;
1002 if (decoder != null)
1003 {
1004 iSO2022Modes = decoder.currentMode;
1005 if (decoder.bytesLeftOverCount != 0)
1006 {
1007 num = decoder.bytesLeftOver[0];
1008 }
1009 }
1010 while (encodingCharBuffer.MoreData || num >= 0)
1011 {
1012 byte b;
1013 if (num >= 0)
1014 {
1015 b = (byte)num;
1016 num = -1;
1017 }
1018 else
1019 {
1020 b = encodingCharBuffer.GetNextByte();
1021 }
1022 if (b == 126)
1023 {
1024 if (!encodingCharBuffer.MoreData)
1025 {
1026 if (decoder == null || decoder.MustFlush)
1027 {
1028 encodingCharBuffer.Fallback(b);
1029 break;
1030 }
1031 decoder.ClearMustFlush();
1032 if (chars != null)
1033 {
1034 decoder.bytesLeftOverCount = 1;
1035 decoder.bytesLeftOver[0] = 126;
1036 flag = true;
1037 }
1038 break;
1039 }
1040 b = encodingCharBuffer.GetNextByte();
1041 if (b == 126 && iSO2022Modes == ISO2022Modes.ModeASCII)
1042 {
1043 if (!encodingCharBuffer.AddChar((char)b, 2))
1044 {
1045 break;
1046 }
1047 continue;
1048 }
1049 if (b == 123)
1050 {
1051 iSO2022Modes = ISO2022Modes.ModeHZ;
1052 continue;
1053 }
1054 if (b == 125)
1055 {
1056 iSO2022Modes = ISO2022Modes.ModeASCII;
1057 continue;
1058 }
1059 if (b == 10)
1060 {
1061 continue;
1062 }
1063 encodingCharBuffer.AdjustBytes(-1);
1064 b = 126;
1065 }
1066 if (iSO2022Modes != ISO2022Modes.ModeASCII && b >= 32)
1067 {
1068 if (!encodingCharBuffer.MoreData)
1069 {
1070 if (decoder == null || decoder.MustFlush)
1071 {
1072 encodingCharBuffer.Fallback(b);
1073 break;
1074 }
1075 decoder.ClearMustFlush();
1076 if (chars != null)
1077 {
1078 decoder.bytesLeftOverCount = 1;
1079 decoder.bytesLeftOver[0] = b;
1080 flag = true;
1081 }
1082 break;
1083 }
1084 byte nextByte = encodingCharBuffer.GetNextByte();
1085 ushort num2 = (ushort)((b << 8) | nextByte);
1086 char c;
1087 if (b == 32 && nextByte != 0)
1088 {
1089 c = (char)nextByte;
1090 }
1091 else
1092 {
1093 if ((b < 33 || b > 119 || nextByte < 33 || nextByte > 126) && (b < 161 || b > 247 || nextByte < 161 || nextByte > 254))
1094 {
1095 if (nextByte != 32 || 33 > b || b > 125)
1096 {
1097 if (!encodingCharBuffer.Fallback((byte)(num2 >> 8), (byte)num2))
1098 {
1099 break;
1100 }
1101 continue;
1102 }
1103 num2 = 8481;
1104 }
1105 num2 = (ushort)(num2 | 0x8080u);
1106 c = mapBytesToUnicode[(int)num2];
1107 }
1108 if (c == '\0' && num2 != 0)
1109 {
1110 if (!encodingCharBuffer.Fallback((byte)(num2 >> 8), (byte)num2))
1111 {
1112 break;
1113 }
1114 }
1115 else if (!encodingCharBuffer.AddChar(c, 2))
1116 {
1117 break;
1118 }
1119 continue;
1120 }
1121 char c2 = mapBytesToUnicode[(int)b];
1122 if ((c2 == '\0' || c2 == '\0') && b != 0)
1123 {
1124 if (!encodingCharBuffer.Fallback(b))
1125 {
1126 break;
1127 }
1128 }
1129 else if (!encodingCharBuffer.AddChar(c2))
1130 {
1131 break;
1132 }
1133 }
1134 if (chars != null && decoder != null)
1135 {
1136 if (!flag)
1137 {
1138 decoder.bytesLeftOverCount = 0;
1139 }
1140 if (decoder.MustFlush && decoder.bytesLeftOverCount == 0)
1141 {
1142 decoder.currentMode = ISO2022Modes.ModeASCII;
1143 }
1144 else
1145 {
1146 decoder.currentMode = iSO2022Modes;
1147 }
1148 decoder.m_bytesUsed = encodingCharBuffer.BytesUsed;
1149 }
1150 return encodingCharBuffer.Count;
1151 }

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.DecoderNLS.ClearMustFlush(), System.Text.Encoding.EncodingCharBuffer.Count, System.Text.ISO2022Encoding.ISO2022Decoder.currentMode, 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().