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

◆ GetBytes() [8/9]

unsafe override int System.Text.UTF8Encoding.GetBytes ( string s,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex )
inlinevirtualinherited

Reimplemented from System.Text.Encoding.

Definition at line 224 of file UTF8Encoding.cs.

225 {
226 if (s == null || bytes == null)
227 {
228 ThrowHelper.ThrowArgumentNullException((s == null) ? ExceptionArgument.s : ExceptionArgument.bytes, ExceptionResource.ArgumentNull_Array);
229 }
230 if ((charIndex | charCount) < 0)
231 {
232 ThrowHelper.ThrowArgumentOutOfRangeException((charIndex < 0) ? ExceptionArgument.charIndex : ExceptionArgument.charCount, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
233 }
234 if (s.Length - charIndex < charCount)
235 {
236 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.s, ExceptionResource.ArgumentOutOfRange_IndexCount);
237 }
238 if ((uint)byteIndex > bytes.Length)
239 {
240 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.byteIndex, ExceptionResource.ArgumentOutOfRange_Index);
241 }
242 fixed (char* ptr2 = s)
243 {
244 fixed (byte[] array = bytes)
245 {
246 byte* ptr = (byte*)((bytes != null && array.Length != 0) ? System.Runtime.CompilerServices.Unsafe.AsPointer(ref array[0]) : null);
247 return GetBytesCommon(ptr2 + charIndex, charCount, ptr + byteIndex, bytes.Length - byteIndex);
248 }
249 }
250 }
unsafe int GetBytesCommon(char *pChars, int charCount, byte *pBytes, int byteCount)

References System.array, System.byteIndex, System.bytes, System.charCount, System.charIndex, System.Text.UTF8Encoding.GetBytesCommon(), System.s, System.ThrowHelper.ThrowArgumentNullException(), and System.ThrowHelper.ThrowArgumentOutOfRangeException().

Referenced by Terraria.IO.FavoritesFile.Save(), and System.Xml.XmlConverter.ToBytes().