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

◆ GetBytes() [1/10]

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

Definition at line 213 of file Base64Encoding.cs.

214 {
215 if (chars == null)
216 {
217 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars"));
218 }
219 if (charIndex < 0)
220 {
221 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charIndex", System.SR.ValueMustBeNonNegative));
222 }
223 if (charIndex > chars.Length)
224 {
225 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, chars.Length)));
226 }
227 if (charCount < 0)
228 {
229 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charCount", System.SR.ValueMustBeNonNegative));
230 }
231 if (charCount > chars.Length - charIndex)
232 {
233 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charCount", System.SR.Format(System.SR.SizeExceedsRemainingBufferSpace, chars.Length - charIndex)));
234 }
235 if (bytes == null)
236 {
237 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("bytes"));
238 }
239 if (byteIndex < 0)
240 {
241 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteIndex", System.SR.ValueMustBeNonNegative));
242 }
243 if (byteIndex > bytes.Length)
244 {
245 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, bytes.Length)));
246 }
247 if (charCount == 0)
248 {
249 return 0;
250 }
251 if (charCount % 4 != 0)
252 {
254 }
255 fixed (byte* ptr7 = &Char2val[0])
256 {
257 fixed (byte* ptr = &chars[charIndex])
258 {
259 fixed (byte* ptr4 = &bytes[byteIndex])
260 {
261 byte* ptr2 = ptr;
262 byte* ptr3 = ptr + charCount;
263 byte* ptr5 = ptr4;
264 byte* ptr6 = ptr4 + bytes.Length - byteIndex;
265 for (; ptr2 < ptr3; ptr2 += 4)
266 {
267 byte b = *ptr2;
268 byte b2 = ptr2[1];
269 byte b3 = ptr2[2];
270 byte b4 = ptr2[3];
271 if ((b | b2 | b3 | b4) >= 128)
272 {
274 }
275 int num = ptr7[(int)b];
276 int num2 = ptr7[(int)b2];
277 int num3 = ptr7[(int)b3];
278 int num4 = ptr7[(int)b4];
280 {
282 }
283 int num5 = ((num4 != 64) ? 3 : ((num3 == 64) ? 1 : 2));
284 if (ptr5 + num5 > ptr6)
285 {
287 }
288 *ptr5 = (byte)((uint)(num << 2) | ((uint)(num2 >> 4) & 3u));
289 if (num5 > 1)
290 {
291 ptr5[1] = (byte)((uint)(num2 << 4) | ((uint)(num3 >> 2) & 0xFu));
292 if (num5 > 2)
293 {
294 ptr5[2] = (byte)((uint)(num3 << 6) | ((uint)num4 & 0x3Fu));
295 }
296 }
297 ptr5 += num5;
298 }
299 return (int)(ptr5 - ptr4);
300 }
301 }
302 }
303 }
static string XmlInvalidBase64Sequence
Definition SR.cs:334
static string XmlInvalidBase64Length
Definition SR.cs:332
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ValueMustBeNonNegative
Definition SR.cs:296
static string SizeExceedsRemainingBufferSpace
Definition SR.cs:324
static string OffsetExceedsBufferSize
Definition SR.cs:322
static string XmlArrayTooSmall
Definition SR.cs:348
Definition SR.cs:7
bool IsValidTailBytes(int v3, int v4)
static ReadOnlySpan< byte > Char2val
bool IsValidLeadBytes(int v1, int v2, int v3, int v4)

References System.byteIndex, System.bytes, System.Text.Base64Encoding.Char2val, System.charCount, System.charIndex, System.chars, System.Runtime.Serialization.Dictionary, System.SR.Format(), System.Text.Base64Encoding.IsValidLeadBytes(), System.Text.Base64Encoding.IsValidTailBytes(), System.SR.OffsetExceedsBufferSize, System.SR.SizeExceedsRemainingBufferSpace, System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(), System.SR.ValueMustBeNonNegative, System.SR.XmlArrayTooSmall, System.SR.XmlInvalidBase64Length, and System.SR.XmlInvalidBase64Sequence.