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

◆ GetBytes() [5/11]

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

Definition at line 104 of file OSEncoding.cs.

105 {
106 if (chars == null || bytes == null)
107 {
108 throw new ArgumentNullException((chars == null) ? "chars" : "bytes", System.SR.ArgumentNull_Array);
109 }
110 if (charIndex < 0 || charCount < 0)
111 {
112 throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
113 }
114 if (chars.Length - charIndex < charCount)
115 {
116 throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
117 }
118 if (byteIndex < 0 || byteIndex > bytes.Length)
119 {
120 throw new ArgumentOutOfRangeException("byteIndex", System.SR.ArgumentOutOfRange_Index);
121 }
122 if (charCount == 0)
123 {
124 return 0;
125 }
126 if (bytes.Length == 0)
127 {
128 throw new ArgumentOutOfRangeException(System.SR.Argument_EncodingConversionOverflowBytes);
129 }
130 fixed (char* ptr = chars)
131 {
132 fixed (byte* ptr2 = &bytes[0])
133 {
134 return WideCharToMultiByte(_codePage, ptr + charIndex, charCount, ptr2 + byteIndex, bytes.Length - byteIndex);
135 }
136 }
137 }
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string Argument_EncodingConversionOverflowBytes
Definition SR.cs:84
static string ArgumentOutOfRange_IndexCountBuffer
Definition SR.cs:78
Definition SR.cs:7
readonly int _codePage
Definition OSEncoding.cs:5
static unsafe int WideCharToMultiByte(int codePage, char *pChars, int count, byte *pBytes, int byteCount)

References System.Text.OSEncoding._codePage, System.SR.Argument_EncodingConversionOverflowBytes, 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.OSEncoding.WideCharToMultiByte().