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

◆ Convert() [2/3]

virtual void System.Text.Encoder.Convert ( char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex,
int byteCount,
bool flush,
out int charsUsed,
out int bytesUsed,
out bool completed )
inlinevirtualinherited

Reimplemented in System.Text.OSEncoder, System.Text.OSEncoder, System.Text.EncoderNLS, and System.Text.EncoderNLS.

Definition at line 135 of file Encoder.cs.

136 {
137 if (chars == null || bytes == null)
138 {
139 throw new ArgumentNullException((chars == null) ? "chars" : "bytes", SR.ArgumentNull_Array);
140 }
141 if (charIndex < 0 || charCount < 0)
142 {
143 throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", SR.ArgumentOutOfRange_NeedNonNegNum);
144 }
145 if (byteIndex < 0 || byteCount < 0)
146 {
147 throw new ArgumentOutOfRangeException((byteIndex < 0) ? "byteIndex" : "byteCount", SR.ArgumentOutOfRange_NeedNonNegNum);
148 }
149 if (chars.Length - charIndex < charCount)
150 {
151 throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer);
152 }
153 if (bytes.Length - byteIndex < byteCount)
154 {
155 throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer);
156 }
157 for (charsUsed = charCount; charsUsed > 0; charsUsed /= 2)
158 {
159 if (GetByteCount(chars, charIndex, charsUsed, flush) <= byteCount)
160 {
161 bytesUsed = GetBytes(chars, charIndex, charsUsed, bytes, byteIndex, flush);
162 completed = charsUsed == charCount && (_fallbackBuffer == null || _fallbackBuffer.Remaining == 0);
163 return;
164 }
165 flush = false;
166 }
167 throw new ArgumentException(SR.Argument_ConversionOverflow);
168 }
int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
EncoderFallbackBuffer _fallbackBuffer
Definition Encoder.cs:9
int GetByteCount(char[] chars, int index, int count, bool flush)

References System.Text.Encoder._fallbackBuffer, System.SR.Argument_ConversionOverflow, System.SR.ArgumentNull_Array, System.SR.ArgumentOutOfRange_IndexCountBuffer, System.SR.ArgumentOutOfRange_NeedNonNegNum, System.byteCount, System.byteIndex, System.bytes, System.charCount, System.charIndex, System.chars, System.Text.Encoder.GetByteCount(), and System.Text.Encoder.GetBytes().

Referenced by System.Text.Encoder.Convert(), System.Text.EncodingExtensions.Convert(), System.Text.EncodingExtensions.Convert(), System.Xml.XmlEncodedRawTextWriter.EncodeChars(), System.Xml.XmlEncodedRawTextWriter.EncodeCharsAsync(), System.Xml.XmlEncodedRawTextWriter.FlushEncoder(), System.Xml.XmlEncodedRawTextWriter.FlushEncoderAsync(), System.Text.TranscodingStream.Write(), System.Text.TranscodingStream.WriteAsync(), and System.IO.BinaryWriter.WriteCharsCommonWithoutLengthPrefix().