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

◆ GetBytes() [7/10]

override int System.Formats.Asn1.BMPEncoding.GetBytes ( ReadOnlySpan< char > chars,
Span< byte > bytes,
bool write )
inlineprotected

Definition at line 5 of file BMPEncoding.cs.

6 {
7 if (chars.IsEmpty)
8 {
9 return 0;
10 }
11 int num = 0;
12 for (int i = 0; i < chars.Length; i++)
13 {
14 char c = chars[i];
15 if (char.IsSurrogate(c))
16 {
17 base.EncoderFallback.CreateFallbackBuffer().Fallback(c, i);
18 throw new InvalidOperationException();
19 }
20 ushort num2 = c;
21 if (write)
22 {
23 bytes[num + 1] = (byte)num2;
24 bytes[num] = (byte)(num2 >> 8);
25 }
26 num += 2;
27 }
28 return num;
29 }

References System.bytes, and System.chars.