Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Ucs4Decoder.cs
Go to the documentation of this file.
1using System.Text;
2
3namespace System.Xml;
4
5internal abstract class Ucs4Decoder : Decoder
6{
7 internal byte[] lastBytes = new byte[4];
8
9 internal int lastBytesCount;
10
11 public override int GetCharCount(byte[] bytes, int index, int count)
12 {
13 return (count + lastBytesCount) / 4;
14 }
15
16 internal abstract int GetFullChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex);
17
18 public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
19 {
20 int num = lastBytesCount;
21 if (lastBytesCount > 0)
22 {
24 {
26 byteIndex++;
27 byteCount--;
29 }
30 if (lastBytesCount < 4)
31 {
32 return 0;
33 }
35 charIndex += num;
37 }
38 else
39 {
40 num = 0;
41 }
43 int num2 = byteCount & 3;
44 if (num2 >= 0)
45 {
46 for (int i = 0; i < num2; i++)
47 {
49 }
51 }
52 return num;
53 }
54
55 public override void Convert(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
56 {
57 bytesUsed = 0;
58 charsUsed = 0;
59 int num = 0;
60 int i = lastBytesCount;
61 if (i > 0)
62 {
63 for (; i < 4; i++)
64 {
65 if (byteCount <= 0)
66 {
67 break;
68 }
70 byteIndex++;
71 byteCount--;
72 bytesUsed++;
73 }
74 if (i < 4)
75 {
77 completed = true;
78 return;
79 }
81 charIndex += num;
82 charCount -= num;
83 charsUsed = num;
85 }
86 else
87 {
88 num = 0;
89 }
90 if (charCount * 4 < byteCount)
91 {
92 byteCount = charCount * 4;
93 completed = false;
94 }
95 else
96 {
97 completed = true;
98 }
99 bytesUsed += byteCount;
100 charsUsed = GetFullChars(bytes, byteIndex, byteCount, chars, charIndex) + num;
101 int num2 = byteCount & 3;
102 if (num2 >= 0)
103 {
104 for (int j = 0; j < num2; j++)
105 {
107 }
109 }
110 }
111
112 internal void Ucs4ToUTF16(uint code, char[] chars, int charIndex)
113 {
114 chars[charIndex] = (char)(55296 + (ushort)((code >> 16) - 1) + (ushort)((code >> 10) & 0x3F));
115 chars[charIndex + 1] = (char)(56320 + (ushort)(code & 0x3FF));
116 }
117}
void Ucs4ToUTF16(uint code, char[] chars, int charIndex)
override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
int GetFullChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
override void Convert(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
override int GetCharCount(byte[] bytes, int index, int count)