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

◆ GetBytes() [2/5]

unsafe override int System.Text.OSEncoder.GetBytes ( char * chars,
int charCount,
byte * bytes,
int byteCount,
bool flush )
inlinevirtual

Reimplemented from System.Text.Encoder.

Definition at line 133 of file OSEncoder.cs.

134 {
135 if (chars == null || bytes == null)
136 {
137 throw new ArgumentNullException((chars == null) ? "chars" : "bytes", System.SR.ArgumentNull_Array);
138 }
139 if (byteCount < 0 || charCount < 0)
140 {
141 throw new ArgumentOutOfRangeException((byteCount < 0) ? "byteCount" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
142 }
143 if (byteCount == 0)
144 {
145 return 0;
146 }
147 char c = ((charCount > 0 && !flush && char.IsHighSurrogate(chars[charCount - 1])) ? chars[charCount - 1] : '\0');
148 if (c != 0)
149 {
150 charCount--;
151 }
152 if (_charLeftOver == '\0')
153 {
154 if (charCount <= 0)
155 {
156 _charLeftOver = c;
157 return 0;
158 }
159 int result = OSEncoding.WideCharToMultiByte(_encoding.CodePage, chars, charCount, bytes, byteCount);
160 _charLeftOver = c;
161 return result;
162 }
163 if (charCount == 0 && c == '\0' && !flush)
164 {
165 return 0;
166 }
168 _charLeftOver = c;
169 return result2;
170 }
virtual int CodePage
Definition Encoding.cs:515
unsafe int ConvertWithLeftOverChar(char *chars, int count, byte *bytes, int byteCount)
Definition OSEncoder.cs:48
readonly Encoding _encoding
Definition OSEncoder.cs:9

References System.Text.OSEncoder._charLeftOver, System.Text.OSEncoder._encoding, System.SR.ArgumentNull_Array, System.SR.ArgumentOutOfRange_NeedNonNegNum, System.byteCount, System.bytes, System.charCount, System.chars, System.Text.Encoding.CodePage, System.Text.OSEncoder.ConvertWithLeftOverChar(), and System.Text.OSEncoding.WideCharToMultiByte().