Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SpanBasedEncoding.cs
Go to the documentation of this file.
1using System.Text;
2
3namespace System.Formats.Asn1;
4
5internal abstract class SpanBasedEncoding : Encoding
6{
7 protected SpanBasedEncoding()
8 : base(0, System.Text.EncoderFallback.ExceptionFallback, System.Text.DecoderFallback.ExceptionFallback)
9 {
10 }
11
12 protected abstract int GetBytes(ReadOnlySpan<char> chars, Span<byte> bytes, bool write);
13
14 protected abstract int GetChars(ReadOnlySpan<byte> bytes, Span<char> chars, bool write);
15
16 public override int GetByteCount(char[] chars, int index, int count)
17 {
19 }
20
21 public unsafe override int GetByteCount(char* chars, int count)
22 {
24 }
25
26 public override int GetByteCount(string s)
27 {
28 return GetByteCount(s.AsSpan());
29 }
30
32 {
33 return GetBytes(chars, Span<byte>.Empty, write: false);
34 }
35
36 public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
37 {
38 return GetBytes(new ReadOnlySpan<char>(chars, charIndex, charCount), new Span<byte>(bytes, byteIndex, bytes.Length - byteIndex), write: true);
39 }
40
41 public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
42 {
43 return GetBytes(new ReadOnlySpan<char>(chars, charCount), new Span<byte>(bytes, byteCount), write: true);
44 }
45
46 public override int GetCharCount(byte[] bytes, int index, int count)
47 {
49 }
50
51 public unsafe override int GetCharCount(byte* bytes, int count)
52 {
54 }
55
57 {
58 return GetChars(bytes, Span<char>.Empty, write: false);
59 }
60
61 public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
62 {
63 return GetChars(new ReadOnlySpan<byte>(bytes, byteIndex, byteCount), new Span<char>(chars, charIndex, chars.Length - charIndex), write: true);
64 }
65
66 public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
67 {
68 return GetChars(new ReadOnlySpan<byte>(bytes, byteCount), new Span<char>(chars, charCount), write: true);
69 }
70}
override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
override int GetByteCount(char[] chars, int index, int count)
override int GetCharCount(ReadOnlySpan< byte > bytes)
unsafe override int GetByteCount(char *chars, int count)
unsafe override int GetCharCount(byte *bytes, int count)
int GetChars(ReadOnlySpan< byte > bytes, Span< char > chars, bool write)
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount)
int GetBytes(ReadOnlySpan< char > chars, Span< byte > bytes, bool write)
override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
override int GetByteCount(ReadOnlySpan< char > chars)
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount)
override int GetCharCount(byte[] bytes, int index, int count)