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

◆ GetBytesCP5022xJP()

unsafe int System.Text.ISO2022Encoding.GetBytesCP5022xJP ( char * chars,
int charCount,
byte * bytes,
int byteCount,
ISO2022Encoder encoder )
inlineprivate

Definition at line 280 of file ISO2022Encoding.cs.

281 {
282 EncodingByteBuffer encodingByteBuffer = new EncodingByteBuffer(this, encoder, bytes, byteCount, chars, charCount);
283 ISO2022Modes iSO2022Modes = ISO2022Modes.ModeASCII;
284 ISO2022Modes iSO2022Modes2 = ISO2022Modes.ModeASCII;
285 if (encoder != null)
286 {
287 char charLeftOver = encoder.charLeftOver;
288 iSO2022Modes = encoder.currentMode;
289 iSO2022Modes2 = encoder.shiftInOutMode;
290 if (charLeftOver > '\0')
291 {
292 encodingByteBuffer.Fallback(charLeftOver);
293 }
294 }
295 while (encodingByteBuffer.MoreData)
296 {
297 char nextChar = encodingByteBuffer.GetNextChar();
298 ushort num = mapUnicodeToBytes[(int)nextChar];
299 byte b;
300 byte b2;
301 while (true)
302 {
303 b = (byte)(num >> 8);
304 b2 = (byte)(num & 0xFFu);
305 if (b != 16)
306 {
307 break;
308 }
309 if (CodePage == 50220)
310 {
311 if (b2 >= 33 && b2 < 33 + s_HalfToFullWidthKanaTable.Length)
312 {
313 num = (ushort)(s_HalfToFullWidthKanaTable[b2 - 33] & 0x7F7Fu);
314 continue;
315 }
316 goto IL_009a;
317 }
318 goto IL_00be;
319 }
320 if (b != 0)
321 {
322 if (CodePage == 50222 && iSO2022Modes == ISO2022Modes.ModeHalfwidthKatakana)
323 {
324 if (!encodingByteBuffer.AddByte(15))
325 {
326 break;
327 }
328 iSO2022Modes = iSO2022Modes2;
329 }
330 if (iSO2022Modes != ISO2022Modes.ModeJIS0208)
331 {
332 if (!encodingByteBuffer.AddByte((byte)27, (byte)36, (byte)66))
333 {
334 break;
335 }
336 iSO2022Modes = ISO2022Modes.ModeJIS0208;
337 }
338 if (!encodingByteBuffer.AddByte(b, b2))
339 {
340 break;
341 }
342 }
343 else if (num != 0 || nextChar == '\0')
344 {
345 if (CodePage == 50222 && iSO2022Modes == ISO2022Modes.ModeHalfwidthKatakana)
346 {
347 if (!encodingByteBuffer.AddByte(15))
348 {
349 break;
350 }
351 iSO2022Modes = iSO2022Modes2;
352 }
353 if (iSO2022Modes != ISO2022Modes.ModeASCII)
354 {
355 if (!encodingByteBuffer.AddByte((byte)27, (byte)40, (byte)66))
356 {
357 break;
358 }
359 iSO2022Modes = ISO2022Modes.ModeASCII;
360 }
361 if (!encodingByteBuffer.AddByte(b2))
362 {
363 break;
364 }
365 }
366 else
367 {
368 encodingByteBuffer.Fallback(nextChar);
369 }
370 continue;
371 IL_009a:
372 encodingByteBuffer.Fallback(nextChar);
373 continue;
374 IL_00be:
375 if (iSO2022Modes != 0)
376 {
377 if (CodePage == 50222)
378 {
379 if (!encodingByteBuffer.AddByte(14))
380 {
381 break;
382 }
383 iSO2022Modes2 = iSO2022Modes;
384 iSO2022Modes = ISO2022Modes.ModeHalfwidthKatakana;
385 }
386 else
387 {
388 if (!encodingByteBuffer.AddByte((byte)27, (byte)40, (byte)73))
389 {
390 break;
391 }
392 iSO2022Modes = ISO2022Modes.ModeHalfwidthKatakana;
393 }
394 }
395 if (!encodingByteBuffer.AddByte((byte)(b2 & 0x7Fu)))
396 {
397 break;
398 }
399 }
400 if (iSO2022Modes != ISO2022Modes.ModeASCII && (encoder == null || encoder.MustFlush))
401 {
402 if (CodePage == 50222 && iSO2022Modes == ISO2022Modes.ModeHalfwidthKatakana)
403 {
404 if (encodingByteBuffer.AddByte(15))
405 {
406 iSO2022Modes = iSO2022Modes2;
407 }
408 else
409 {
410 encodingByteBuffer.GetNextChar();
411 }
412 }
413 if (iSO2022Modes != ISO2022Modes.ModeASCII && (CodePage != 50222 || iSO2022Modes != 0))
414 {
415 if (encodingByteBuffer.AddByte((byte)27, (byte)40, (byte)66))
416 {
417 iSO2022Modes = ISO2022Modes.ModeASCII;
418 }
419 else
420 {
421 encodingByteBuffer.GetNextChar();
422 }
423 }
424 }
425 if (bytes != null && encoder != null)
426 {
427 encoder.currentMode = iSO2022Modes;
428 encoder.shiftInOutMode = iSO2022Modes2;
429 if (!encodingByteBuffer.fallbackBufferHelper.bUsedEncoder)
430 {
431 encoder.charLeftOver = '\0';
432 }
433 encoder.m_charsUsed = encodingByteBuffer.CharsUsed;
434 }
435 return encodingByteBuffer.Count;
436 }
virtual int CodePage
Definition Encoding.cs:515
static readonly ushort[] s_HalfToFullWidthKanaTable

References System.Text.Encoding.EncodingByteBuffer.AddByte(), System.byteCount, System.bytes, System.charCount, System.Text.EncoderNLS.charLeftOver, System.chars, System.Text.Encoding.EncodingByteBuffer.CharsUsed, System.Text.Encoding.CodePage, System.Text.Encoding.EncodingByteBuffer.Count, System.Text.ISO2022Encoding.ISO2022Encoder.currentMode, System.Text.Encoding.EncodingByteBuffer.GetNextChar(), System.Text.DBCSCodePageEncoding.mapUnicodeToBytes, System.Text.Encoding.EncodingByteBuffer.MoreData, System.Text.EncoderNLS.MustFlush, System.Text.ISO2022Encoding.s_HalfToFullWidthKanaTable, and System.Text.ISO2022Encoding.ISO2022Encoder.shiftInOutMode.

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