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

◆ CleanUpBytes()

override bool System.Text.ISO2022Encoding.CleanUpBytes ( ref int bytes)
inlineprotectedvirtual

Reimplemented from System.Text.DBCSCodePageEncoding.

Definition at line 117 of file ISO2022Encoding.cs.

118 {
119 switch (CodePage)
120 {
121 case 50220:
122 case 50221:
123 case 50222:
124 if (bytes >= 256)
125 {
126 if (bytes >= 64064 && bytes <= 64587)
127 {
128 if (bytes >= 64064 && bytes <= 64091)
129 {
130 if (bytes <= 64073)
131 {
132 bytes -= 2897;
133 }
134 else if (bytes >= 64074 && bytes <= 64083)
135 {
136 bytes -= 29430;
137 }
138 else if (bytes >= 64084 && bytes <= 64087)
139 {
140 bytes -= 2907;
141 }
142 else if (bytes == 64088)
143 {
144 bytes = 34698;
145 }
146 else if (bytes == 64089)
147 {
148 bytes = 34690;
149 }
150 else if (bytes == 64090)
151 {
152 bytes = 34692;
153 }
154 else if (bytes == 64091)
155 {
156 bytes = 34714;
157 }
158 }
159 else if (bytes >= 64092 && bytes <= 64587)
160 {
161 byte b = (byte)bytes;
162 if (b < 92)
163 {
164 bytes -= 3423;
165 }
166 else if (b >= 128 && b <= 155)
167 {
168 bytes -= 3357;
169 }
170 else
171 {
172 bytes -= 3356;
173 }
174 }
175 }
176 byte b2 = (byte)(bytes >> 8);
177 byte b3 = (byte)bytes;
178 b2 = (byte)(b2 - ((b2 > 159) ? 177 : 113));
179 b2 = (byte)((b2 << 1) + 1);
180 if (b3 > 158)
181 {
182 b3 -= 126;
183 b2++;
184 }
185 else
186 {
187 if (b3 > 126)
188 {
189 b3--;
190 }
191 b3 -= 31;
192 }
193 bytes = (b2 << 8) | b3;
194 }
195 else
196 {
197 if (bytes >= 161 && bytes <= 223)
198 {
199 bytes += 3968;
200 }
201 if (bytes >= 129 && (bytes <= 159 || (bytes >= 224 && bytes <= 252)))
202 {
203 return false;
204 }
205 }
206 break;
207 case 50225:
208 if (bytes >= 128 && bytes <= 255)
209 {
210 return false;
211 }
212 if (bytes >= 256 && ((bytes & 0xFF) < 161 || (bytes & 0xFF) == 255 || (bytes & 0xFF00) < 41216 || (bytes & 0xFF00) == 65280))
213 {
214 return false;
215 }
216 bytes &= 32639;
217 break;
218 case 52936:
219 if (bytes >= 129 && bytes <= 254)
220 {
221 return false;
222 }
223 break;
224 }
225 return true;
226 }
virtual int CodePage
Definition Encoding.cs:515

References System.bytes, and System.Text.Encoding.CodePage.