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

◆ GetBytes() [4/5]

unsafe override int System.Text.OSEncoder.GetBytes ( char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex,
bool flush )
inline

Definition at line 96 of file OSEncoder.cs.

97 {
98 if (chars == null || bytes == null)
99 {
100 throw new ArgumentNullException((chars == null) ? "chars" : "bytes", System.SR.ArgumentNull_Array);
101 }
102 if (charIndex < 0 || charCount < 0)
103 {
104 throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
105 }
106 if (chars.Length - charIndex < charCount)
107 {
108 throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
109 }
110 if (byteIndex < 0 || byteIndex > bytes.Length)
111 {
112 throw new ArgumentOutOfRangeException("byteIndex", System.SR.ArgumentOutOfRange_Index);
113 }
114 if (bytes.Length == 0)
115 {
116 return 0;
117 }
118 if (charCount == 0 && (_charLeftOver == '\0' || !flush))
119 {
120 return 0;
121 }
122 fixed (char* ptr = chars)
123 {
124 fixed (byte* ptr2 = &bytes[0])
125 {
126 Unsafe.SkipInit(out char c);
127 char* chars2 = ((ptr == null) ? (&c) : (ptr + charIndex));
128 return GetBytes(chars2, charCount, ptr2 + byteIndex, bytes.Length - byteIndex, flush);
129 }
130 }
131 }
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string ArgumentOutOfRange_IndexCountBuffer
Definition SR.cs:78
Definition SR.cs:7
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
Definition OSEncoder.cs:96

References System.Text.OSEncoder._charLeftOver, System.SR.ArgumentNull_Array, System.SR.ArgumentOutOfRange_Index, System.SR.ArgumentOutOfRange_IndexCountBuffer, System.SR.ArgumentOutOfRange_NeedNonNegNum, System.byteIndex, System.bytes, System.charCount, System.charIndex, System.chars, and System.Text.OSEncoder.GetBytes().