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

◆ CleanUpBytes()

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

Reimplemented from System.Text.DBCSCodePageEncoding.

Definition at line 10 of file EUCJPEncoding.cs.

11 {
12 if (bytes >= 256)
13 {
14 if (bytes >= 64064 && bytes <= 64587)
15 {
16 if (bytes >= 64064 && bytes <= 64091)
17 {
18 if (bytes <= 64073)
19 {
20 bytes -= 2897;
21 }
22 else if (bytes >= 64074 && bytes <= 64083)
23 {
24 bytes -= 29430;
25 }
26 else if (bytes >= 64084 && bytes <= 64087)
27 {
28 bytes -= 2907;
29 }
30 else if (bytes == 64088)
31 {
32 bytes = 34698;
33 }
34 else if (bytes == 64089)
35 {
36 bytes = 34690;
37 }
38 else if (bytes == 64090)
39 {
40 bytes = 34692;
41 }
42 else if (bytes == 64091)
43 {
44 bytes = 34714;
45 }
46 }
47 else if (bytes >= 64092 && bytes <= 64587)
48 {
49 byte b = (byte)bytes;
50 if (b < 92)
51 {
52 bytes -= 3423;
53 }
54 else if (b >= 128 && b <= 155)
55 {
56 bytes -= 3357;
57 }
58 else
59 {
60 bytes -= 3356;
61 }
62 }
63 }
64 byte b2 = (byte)(bytes >> 8);
65 byte b3 = (byte)bytes;
66 b2 = (byte)(b2 - ((b2 > 159) ? 177 : 113));
67 b2 = (byte)((b2 << 1) + 1);
68 if (b3 > 158)
69 {
70 b3 -= 126;
71 b2++;
72 }
73 else
74 {
75 if (b3 > 126)
76 {
77 b3--;
78 }
79 b3 -= 31;
80 }
81 bytes = (b2 << 8) | b3 | 0x8080;
82 if ((bytes & 0xFF00) < 41216 || (bytes & 0xFF00) > 65024 || (bytes & 0xFF) < 161 || (bytes & 0xFF) > 254)
83 {
84 return false;
85 }
86 }
87 else
88 {
89 if (bytes >= 161 && bytes <= 223)
90 {
91 bytes |= 36352;
92 return true;
93 }
94 if (bytes >= 129 && bytes != 160 && bytes != 255)
95 {
96 return false;
97 }
98 }
99 return true;
100 }

References System.bytes.