Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Ucs4Decoder.cs
Go to the documentation of this file.
1
using
System.Text
;
2
3
namespace
System.Xml
;
4
5
internal
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
{
23
while
(
lastBytesCount < 4 && byteCount >
0)
24
{
25
lastBytes
[
lastBytesCount
] =
bytes
[
byteIndex
];
26
byteIndex
++;
27
byteCount
--;
28
lastBytesCount
++;
29
}
30
if
(
lastBytesCount
< 4)
31
{
32
return
0;
33
}
34
num =
GetFullChars
(
lastBytes
, 0, 4,
chars
,
charIndex
);
35
charIndex
+= num;
36
lastBytesCount
= 0;
37
}
38
else
39
{
40
num = 0;
41
}
42
num =
GetFullChars
(
bytes
,
byteIndex
,
byteCount
,
chars
,
charIndex
) + num;
43
int
num2
=
byteCount
& 3;
44
if
(
num2
>= 0)
45
{
46
for
(
int
i = 0; i <
num2
; i++)
47
{
48
lastBytes
[i] =
bytes
[
byteIndex
+
byteCount
-
num2
+ i];
49
}
50
lastBytesCount
=
num2
;
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
}
69
lastBytes
[i] =
bytes
[
byteIndex
];
70
byteIndex
++;
71
byteCount
--;
72
bytesUsed++;
73
}
74
if
(i < 4)
75
{
76
lastBytesCount
= i;
77
completed
=
true
;
78
return
;
79
}
80
num =
GetFullChars
(
lastBytes
, 0, 4,
chars
,
charIndex
);
81
charIndex
+= num;
82
charCount
-= num;
83
charsUsed = num;
84
lastBytesCount
= 0;
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
{
106
lastBytes
[
j
] =
bytes
[
byteIndex
+
byteCount
-
num2
+
j
];
107
}
108
lastBytesCount
=
num2
;
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
}
System.Text.Decoder
Definition
Decoder.cs:6
System.Xml.Ucs4Decoder.Ucs4ToUTF16
void Ucs4ToUTF16(uint code, char[] chars, int charIndex)
Definition
Ucs4Decoder.cs:112
System.Xml.Ucs4Decoder.lastBytesCount
int lastBytesCount
Definition
Ucs4Decoder.cs:9
System.Xml.Ucs4Decoder.GetChars
override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
Definition
Ucs4Decoder.cs:18
System.Xml.Ucs4Decoder.lastBytes
byte[] lastBytes
Definition
Ucs4Decoder.cs:7
System.Xml.Ucs4Decoder.GetFullChars
int GetFullChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
System.Xml.Ucs4Decoder.Convert
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)
Definition
Ucs4Decoder.cs:55
System.Xml.Ucs4Decoder.GetCharCount
override int GetCharCount(byte[] bytes, int index, int count)
Definition
Ucs4Decoder.cs:11
System.Xml.Ucs4Decoder
Definition
Ucs4Decoder.cs:6
System.Text
Definition
ConsoleEncoding.cs:1
System.Xml.ValueHandleType.Dictionary
@ Dictionary
System.Xml
Definition
BaseRegionIterator.cs:1
System.ExceptionArgument.bytes
@ bytes
System.ExceptionArgument.byteIndex
@ byteIndex
System.ExceptionArgument.index
@ index
System.ExceptionArgument.charCount
@ charCount
System.ExceptionArgument.byteCount
@ byteCount
System.ExceptionArgument.chars
@ chars
System.ExceptionArgument.charIndex
@ charIndex
System.ExceptionArgument.count
@ count
source
System.Private.Xml
System.Xml
Ucs4Decoder.cs
Generated by
1.10.0