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

◆ GetChars() [7/7]

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

Definition at line 31 of file BMPEncoding.cs.

32 {
33 if (bytes.IsEmpty)
34 {
35 return 0;
36 }
37 if (bytes.Length % 2 != 0)
38 {
39 base.DecoderFallback.CreateFallbackBuffer().Fallback(bytes.Slice(bytes.Length - 1).ToArray(), bytes.Length - 1);
40 throw new InvalidOperationException();
41 }
42 int num = 0;
43 for (int i = 0; i < bytes.Length; i += 2)
44 {
45 int num2 = (bytes[i] << 8) | bytes[i + 1];
46 char c = (char)num2;
47 if (char.IsSurrogate(c))
48 {
49 base.DecoderFallback.CreateFallbackBuffer().Fallback(bytes.Slice(i, 2).ToArray(), i);
50 throw new InvalidOperationException();
51 }
52 if (write)
53 {
54 chars[num] = c;
55 }
56 num++;
57 }
58 return num;
59 }

References System.bytes, and System.chars.