Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UTF8Encoding.cs
Go to the documentation of this file.
6
7namespace System.Text;
8
9public class UTF8Encoding : Encoding
10{
11 internal sealed class UTF8EncodingSealed : UTF8Encoding
12 {
14 {
15 get
16 {
18 {
19 return default(ReadOnlySpan<byte>);
20 }
21 return PreambleSpan;
22 }
23 }
24
25 public UTF8EncodingSealed(bool encoderShouldEmitUTF8Identifier)
26 : base(encoderShouldEmitUTF8Identifier)
27 {
28 }
29
30 public override object Clone()
31 {
33 {
34 IsReadOnly = false
35 };
36 }
37
38 public override byte[] GetBytes(string s)
39 {
40 if (s != null && s.Length <= 32)
41 {
43 }
44 return base.GetBytes(s);
45 }
46
47 private unsafe byte[] GetBytesForSmallInput(string s)
48 {
49 byte* ptr = stackalloc byte[96];
50 int length = s.Length;
51 int bytesCommon;
52 fixed (char* pChars = s)
53 {
54 bytesCommon = GetBytesCommon(pChars, length, ptr, 96);
55 }
56 return new Span<byte>(ref *ptr, bytesCommon).ToArray();
57 }
58
59 public override string GetString(byte[] bytes)
60 {
61 if (bytes != null && bytes.Length <= 32)
62 {
64 }
65 return base.GetString(bytes);
66 }
67
68 private unsafe string GetStringForSmallInput(byte[] bytes)
69 {
70 char* ptr = stackalloc char[32];
71 int byteCount = bytes.Length;
72 int charsCommon;
73 fixed (byte* pBytes = bytes)
74 {
75 charsCommon = GetCharsCommon(pBytes, byteCount, ptr, 32);
76 }
77 return new string(new ReadOnlySpan<char>(ref *ptr, charsCommon));
78 }
79 }
80
81 internal static readonly UTF8EncodingSealed s_default = new UTF8EncodingSealed(encoderShouldEmitUTF8Identifier: true);
82
83 private readonly bool _emitUTF8Identifier;
84
85 private readonly bool _isThrowException;
86
87 internal static ReadOnlySpan<byte> PreambleSpan => "\ufeff"u8;
88
90 {
91 get
92 {
93 if (!(GetType() != typeof(UTF8Encoding)))
94 {
96 {
97 return default(ReadOnlySpan<byte>);
98 }
99 return PreambleSpan;
100 }
101 return new ReadOnlySpan<byte>(GetPreamble());
102 }
103 }
104
106 : base(65001)
107 {
108 }
109
110 public UTF8Encoding(bool encoderShouldEmitUTF8Identifier)
111 : this()
112 {
113 _emitUTF8Identifier = encoderShouldEmitUTF8Identifier;
114 }
115
116 public UTF8Encoding(bool encoderShouldEmitUTF8Identifier, bool throwOnInvalidBytes)
117 : this(encoderShouldEmitUTF8Identifier)
118 {
119 _isThrowException = throwOnInvalidBytes;
121 {
123 }
124 }
125
126 internal sealed override void SetDefaultFallbacks()
127 {
129 {
132 }
133 else
134 {
137 }
138 }
139
140 public unsafe override int GetByteCount(char[] chars, int index, int count)
141 {
142 if (chars == null)
143 {
145 }
146 if ((index | count) < 0)
147 {
148 ThrowHelper.ThrowArgumentOutOfRangeException((index < 0) ? ExceptionArgument.index : ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
149 }
150 if (chars.Length - index < count)
151 {
152 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.chars, ExceptionResource.ArgumentOutOfRange_IndexCountBuffer);
153 }
154 fixed (char* ptr = chars)
155 {
156 return GetByteCountCommon(ptr + index, count);
157 }
158 }
159
160 public unsafe override int GetByteCount(string chars)
161 {
162 if (chars == null)
163 {
165 }
166 fixed (char* pChars = chars)
167 {
168 return GetByteCountCommon(pChars, chars.Length);
169 }
170 }
171
172 [CLSCompliant(false)]
173 public unsafe override int GetByteCount(char* chars, int count)
174 {
175 if (chars == null)
176 {
178 }
179 if (count < 0)
180 {
182 }
184 }
185
186 public unsafe override int GetByteCount(ReadOnlySpan<char> chars)
187 {
188 fixed (char* pChars = &MemoryMarshal.GetReference(chars))
189 {
190 return GetByteCountCommon(pChars, chars.Length);
191 }
192 }
193
194 [MethodImpl(MethodImplOptions.AggressiveInlining)]
195 private unsafe int GetByteCountCommon(char* pChars, int charCount)
196 {
197 int charsConsumed;
198 int num = GetByteCountFast(pChars, charCount, null, out charsConsumed);
199 if (charsConsumed != charCount)
200 {
201 num += GetByteCountWithFallback(pChars, charCount, charsConsumed);
202 if (num < 0)
203 {
205 }
206 }
207 return num;
208 }
209
210 [MethodImpl(MethodImplOptions.AggressiveInlining)]
211 private protected unsafe sealed override int GetByteCountFast(char* pChars, int charsLength, EncoderFallback fallback, out int charsConsumed)
212 {
213 long utf8CodeUnitCountAdjustment;
214 int scalarCountAdjustment;
215 char* pointerToFirstInvalidChar = Utf16Utility.GetPointerToFirstInvalidChar(pChars, charsLength, out utf8CodeUnitCountAdjustment, out scalarCountAdjustment);
216 long num = (charsConsumed = (int)(pointerToFirstInvalidChar - pChars)) + utf8CodeUnitCountAdjustment;
217 if ((ulong)num > 2147483647uL)
218 {
220 }
221 return (int)num;
222 }
223
224 public unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
225 {
226 if (s == null || bytes == null)
227 {
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 {
237 }
238 if ((uint)byteIndex > bytes.Length)
239 {
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 }
251
252 public unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
253 {
254 if (chars == null || bytes == null)
255 {
257 }
258 if ((charIndex | charCount) < 0)
259 {
260 ThrowHelper.ThrowArgumentOutOfRangeException((charIndex < 0) ? ExceptionArgument.charIndex : ExceptionArgument.charCount, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
261 }
262 if (chars.Length - charIndex < charCount)
263 {
265 }
266 if ((uint)byteIndex > bytes.Length)
267 {
269 }
270 fixed (char* ptr = chars)
271 {
272 fixed (byte* ptr2 = bytes)
273 {
274 return GetBytesCommon(ptr + charIndex, charCount, ptr2 + byteIndex, bytes.Length - byteIndex);
275 }
276 }
277 }
278
279 [CLSCompliant(false)]
280 public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
281 {
282 if (chars == null || bytes == null)
283 {
285 }
286 if ((charCount | byteCount) < 0)
287 {
288 ThrowHelper.ThrowArgumentOutOfRangeException((charCount < 0) ? ExceptionArgument.charCount : ExceptionArgument.byteCount, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
289 }
291 }
292
293 public unsafe override int GetBytes(ReadOnlySpan<char> chars, Span<byte> bytes)
294 {
295 fixed (char* pChars = &MemoryMarshal.GetReference(chars))
296 {
297 fixed (byte* pBytes = &MemoryMarshal.GetReference(bytes))
298 {
299 return GetBytesCommon(pChars, chars.Length, pBytes, bytes.Length);
300 }
301 }
302 }
303
304 [MethodImpl(MethodImplOptions.AggressiveInlining)]
305 private unsafe int GetBytesCommon(char* pChars, int charCount, byte* pBytes, int byteCount)
306 {
307 int charsConsumed;
308 int bytesFast = GetBytesFast(pChars, charCount, pBytes, byteCount, out charsConsumed);
309 if (charsConsumed == charCount)
310 {
311 return bytesFast;
312 }
313 return GetBytesWithFallback(pChars, charCount, pBytes, byteCount, charsConsumed, bytesFast);
314 }
315
316 [MethodImpl(MethodImplOptions.AggressiveInlining)]
317 private protected unsafe sealed override int GetBytesFast(char* pChars, int charsLength, byte* pBytes, int bytesLength, out int charsConsumed)
318 {
319 Utf8Utility.TranscodeToUtf8(pChars, charsLength, pBytes, bytesLength, out var pInputBufferRemaining, out var pOutputBufferRemaining);
320 charsConsumed = (int)(pInputBufferRemaining - pChars);
321 return (int)(pOutputBufferRemaining - pBytes);
322 }
323
324 public unsafe override int GetCharCount(byte[] bytes, int index, int count)
325 {
326 if (bytes == null)
327 {
329 }
330 if ((index | count) < 0)
331 {
332 ThrowHelper.ThrowArgumentOutOfRangeException((index < 0) ? ExceptionArgument.index : ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
333 }
334 if (bytes.Length - index < count)
335 {
336 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.bytes, ExceptionResource.ArgumentOutOfRange_IndexCountBuffer);
337 }
338 fixed (byte* ptr = bytes)
339 {
340 return GetCharCountCommon(ptr + index, count);
341 }
342 }
343
344 [CLSCompliant(false)]
345 public unsafe override int GetCharCount(byte* bytes, int count)
346 {
347 if (bytes == null)
348 {
350 }
351 if (count < 0)
352 {
354 }
356 }
357
358 public unsafe override int GetCharCount(ReadOnlySpan<byte> bytes)
359 {
360 fixed (byte* pBytes = &MemoryMarshal.GetReference(bytes))
361 {
362 return GetCharCountCommon(pBytes, bytes.Length);
363 }
364 }
365
366 public unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
367 {
368 if (bytes == null || chars == null)
369 {
371 }
372 if ((byteIndex | byteCount) < 0)
373 {
374 ThrowHelper.ThrowArgumentOutOfRangeException((byteIndex < 0) ? ExceptionArgument.byteIndex : ExceptionArgument.byteCount, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
375 }
376 if (bytes.Length - byteIndex < byteCount)
377 {
378 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.bytes, ExceptionResource.ArgumentOutOfRange_IndexCountBuffer);
379 }
380 if ((uint)charIndex > (uint)chars.Length)
381 {
383 }
384 fixed (byte* ptr = bytes)
385 {
386 fixed (char* ptr2 = chars)
387 {
388 return GetCharsCommon(ptr + byteIndex, byteCount, ptr2 + charIndex, chars.Length - charIndex);
389 }
390 }
391 }
392
393 [CLSCompliant(false)]
394 public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
395 {
396 if (bytes == null || chars == null)
397 {
399 }
400 if ((byteCount | charCount) < 0)
401 {
402 ThrowHelper.ThrowArgumentOutOfRangeException((byteCount < 0) ? ExceptionArgument.byteCount : ExceptionArgument.charCount, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
403 }
405 }
406
407 public unsafe override int GetChars(ReadOnlySpan<byte> bytes, Span<char> chars)
408 {
409 fixed (byte* pBytes = &MemoryMarshal.GetReference(bytes))
410 {
411 fixed (char* pChars = &MemoryMarshal.GetReference(chars))
412 {
413 return GetCharsCommon(pBytes, bytes.Length, pChars, chars.Length);
414 }
415 }
416 }
417
418 [MethodImpl(MethodImplOptions.AggressiveInlining)]
419 private unsafe int GetCharsCommon(byte* pBytes, int byteCount, char* pChars, int charCount)
420 {
421 int bytesConsumed;
422 int charsFast = GetCharsFast(pBytes, byteCount, pChars, charCount, out bytesConsumed);
423 if (bytesConsumed == byteCount)
424 {
425 return charsFast;
426 }
427 return GetCharsWithFallback(pBytes, byteCount, pChars, charCount, bytesConsumed, charsFast);
428 }
429
430 [MethodImpl(MethodImplOptions.AggressiveInlining)]
431 private protected unsafe sealed override int GetCharsFast(byte* pBytes, int bytesLength, char* pChars, int charsLength, out int bytesConsumed)
432 {
433 Utf8Utility.TranscodeToUtf16(pBytes, bytesLength, pChars, charsLength, out var pInputBufferRemaining, out var pOutputBufferRemaining);
434 bytesConsumed = (int)(pInputBufferRemaining - pBytes);
435 return (int)(pOutputBufferRemaining - pChars);
436 }
437
438 private protected sealed override int GetCharsWithFallback(ReadOnlySpan<byte> bytes, int originalBytesLength, Span<char> chars, int originalCharsLength, DecoderNLS decoder)
439 {
440 if (((decoder == null) ? base.DecoderFallback : decoder.Fallback) is DecoderReplacementFallback { MaxCharCount: 1 } decoderReplacementFallback && decoderReplacementFallback.DefaultString[0] == '\ufffd')
441 {
442 Utf8.ToUtf16(bytes, chars, out var bytesRead, out var charsWritten, replaceInvalidSequences: true, decoder?.MustFlush ?? true);
443 bytes = bytes.Slice(bytesRead);
444 chars = chars.Slice(charsWritten);
445 }
446 if (bytes.IsEmpty)
447 {
448 return originalCharsLength - chars.Length;
449 }
450 return base.GetCharsWithFallback(bytes, originalBytesLength, chars, originalCharsLength, decoder);
451 }
452
453 public unsafe override string GetString(byte[] bytes, int index, int count)
454 {
455 if (bytes == null)
456 {
458 }
459 if ((index | count) < 0)
460 {
461 ThrowHelper.ThrowArgumentOutOfRangeException((index < 0) ? ExceptionArgument.index : ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
462 }
463 if (bytes.Length - index < count)
464 {
465 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.bytes, ExceptionResource.ArgumentOutOfRange_IndexCountBuffer);
466 }
467 if (count == 0)
468 {
469 return string.Empty;
470 }
471 fixed (byte* ptr = bytes)
472 {
473 return string.CreateStringFromEncoding(ptr + index, count, this);
474 }
475 }
476
477 [MethodImpl(MethodImplOptions.AggressiveInlining)]
478 private unsafe int GetCharCountCommon(byte* pBytes, int byteCount)
479 {
480 int bytesConsumed;
481 int num = GetCharCountFast(pBytes, byteCount, null, out bytesConsumed);
482 if (bytesConsumed != byteCount)
483 {
484 num += GetCharCountWithFallback(pBytes, byteCount, bytesConsumed);
485 if (num < 0)
486 {
488 }
489 }
490 return num;
491 }
492
493 [MethodImpl(MethodImplOptions.AggressiveInlining)]
494 private protected unsafe sealed override int GetCharCountFast(byte* pBytes, int bytesLength, DecoderFallback fallback, out int bytesConsumed)
495 {
496 int utf16CodeUnitCountAdjustment;
497 int scalarCountAdjustment;
498 byte* pointerToFirstInvalidByte = Utf8Utility.GetPointerToFirstInvalidByte(pBytes, bytesLength, out utf16CodeUnitCountAdjustment, out scalarCountAdjustment);
499 return (bytesConsumed = (int)(pointerToFirstInvalidByte - pBytes)) + utf16CodeUnitCountAdjustment;
500 }
501
502 public override Decoder GetDecoder()
503 {
504 return new DecoderNLS(this);
505 }
506
507 public override Encoder GetEncoder()
508 {
509 return new EncoderNLS(this);
510 }
511
512 internal sealed override bool TryGetByteCount(Rune value, out int byteCount)
513 {
514 byteCount = value.Utf8SequenceLength;
515 return true;
516 }
517
518 internal sealed override OperationStatus EncodeRune(Rune value, Span<byte> bytes, out int bytesWritten)
519 {
520 if (!value.TryEncodeToUtf8(bytes, out bytesWritten))
521 {
522 return OperationStatus.DestinationTooSmall;
523 }
524 return OperationStatus.Done;
525 }
526
527 internal sealed override OperationStatus DecodeFirstRune(ReadOnlySpan<byte> bytes, out Rune value, out int bytesConsumed)
528 {
529 return Rune.DecodeFromUtf8(bytes, out value, out bytesConsumed);
530 }
531
532 public override int GetMaxByteCount(int charCount)
533 {
534 if (charCount < 0)
535 {
537 }
538 long num = (long)charCount + 1L;
539 if (base.EncoderFallback.MaxCharCount > 1)
540 {
541 num *= base.EncoderFallback.MaxCharCount;
542 }
543 num *= 3;
544 if (num > int.MaxValue)
545 {
547 }
548 return (int)num;
549 }
550
551 public override int GetMaxCharCount(int byteCount)
552 {
553 if (byteCount < 0)
554 {
556 }
557 long num = (long)byteCount + 1L;
558 if (base.DecoderFallback.MaxCharCount > 1)
559 {
560 num *= base.DecoderFallback.MaxCharCount;
561 }
562 if (num > int.MaxValue)
563 {
565 }
566 return (int)num;
567 }
568
569 public override byte[] GetPreamble()
570 {
572 {
573 return new byte[3] { 239, 187, 191 };
574 }
575 return Array.Empty<byte>();
576 }
577
578 public override bool Equals([NotNullWhen(true)] object? value)
579 {
580 if (value is UTF8Encoding uTF8Encoding)
581 {
582 if (_emitUTF8Identifier == uTF8Encoding._emitUTF8Identifier && base.EncoderFallback.Equals(uTF8Encoding.EncoderFallback))
583 {
584 return base.DecoderFallback.Equals(uTF8Encoding.DecoderFallback);
585 }
586 return false;
587 }
588 return false;
589 }
590
591 public override int GetHashCode()
592 {
593 return base.EncoderFallback.GetHashCode() + base.DecoderFallback.GetHashCode() + 65001 + (_emitUTF8Identifier ? 1 : 0);
594 }
595}
static string ArgumentOutOfRange_GetCharCountOverflow
Definition SR.cs:90
static string ArgumentOutOfRange_GetByteCountOverflow
Definition SR.cs:88
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7
static DecoderFallback ExceptionFallback
new DecoderFallback Fallback
Definition DecoderNLS.cs:19
static EncoderFallback ExceptionFallback
EncoderFallback encoderFallback
Definition Encoding.cs:341
unsafe int GetByteCountWithFallback(char *pCharsOriginal, int originalCharCount, int charsConsumedSoFar)
Definition Encoding.cs:1150
static void ThrowConversionOverflow()
Definition Encoding.cs:1084
unsafe int GetBytesWithFallback(char *pOriginalChars, int originalCharCount, byte *pOriginalBytes, int originalByteCount, int charsConsumedSoFar, int bytesWrittenSoFar)
Definition Encoding.cs:1235
DecoderFallback decoderFallback
Definition Encoding.cs:343
unsafe int GetCharCountWithFallback(byte *pBytesOriginal, int originalByteCount, int bytesConsumedSoFar)
Definition Encoding.cs:1348
UTF8EncodingSealed(bool encoderShouldEmitUTF8Identifier)
unsafe string GetStringForSmallInput(byte[] bytes)
override string GetString(byte[] bytes)
override ReadOnlySpan< byte > Preamble
unsafe byte[] GetBytesForSmallInput(string s)
override int GetCharsWithFallback(ReadOnlySpan< byte > bytes, int originalBytesLength, Span< char > chars, int originalCharsLength, DecoderNLS decoder)
unsafe override int GetCharCountFast(byte *pBytes, int bytesLength, DecoderFallback fallback, out int bytesConsumed)
unsafe override int GetCharsFast(byte *pBytes, int bytesLength, char *pChars, int charsLength, out int bytesConsumed)
unsafe int GetCharsCommon(byte *pBytes, int byteCount, char *pChars, int charCount)
unsafe override int GetByteCount(char[] chars, int index, int count)
unsafe override int GetByteCount(ReadOnlySpan< char > chars)
override OperationStatus EncodeRune(Rune value, Span< byte > bytes, out int bytesWritten)
unsafe override int GetCharCount(ReadOnlySpan< byte > bytes)
UTF8Encoding(bool encoderShouldEmitUTF8Identifier, bool throwOnInvalidBytes)
unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
unsafe override string GetString(byte[] bytes, int index, int count)
unsafe override int GetBytes(ReadOnlySpan< char > chars, Span< byte > bytes)
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount)
override byte[] GetPreamble()
override int GetMaxByteCount(int charCount)
unsafe override int GetByteCount(char *chars, int count)
static ReadOnlySpan< byte > PreambleSpan
readonly bool _emitUTF8Identifier
unsafe int GetBytesCommon(char *pChars, int charCount, byte *pBytes, int byteCount)
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount)
unsafe override int GetByteCountFast(char *pChars, int charsLength, EncoderFallback fallback, out int charsConsumed)
override int GetMaxCharCount(int byteCount)
unsafe override int GetCharCount(byte[] bytes, int index, int count)
unsafe override int GetByteCount(string chars)
override OperationStatus DecodeFirstRune(ReadOnlySpan< byte > bytes, out Rune value, out int bytesConsumed)
override bool TryGetByteCount(Rune value, out int byteCount)
override Decoder GetDecoder()
unsafe int GetCharCountCommon(byte *pBytes, int byteCount)
override int GetHashCode()
static readonly UTF8EncodingSealed s_default
override ReadOnlySpan< byte > Preamble
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
UTF8Encoding(bool encoderShouldEmitUTF8Identifier)
override void SetDefaultFallbacks()
override Encoder GetEncoder()
override bool Equals([NotNullWhen(true)] object? value)
readonly bool _isThrowException
unsafe int GetByteCountCommon(char *pChars, int charCount)
unsafe override int GetCharCount(byte *bytes, int count)
unsafe override int GetChars(ReadOnlySpan< byte > bytes, Span< char > chars)
unsafe override int GetBytesFast(char *pChars, int charsLength, byte *pBytes, int bytesLength, out int charsConsumed)
unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
static unsafe char * GetPointerToFirstInvalidChar(char *pInputBuffer, int inputLength, out long utf8CodeUnitCountAdjustment, out int scalarCountAdjustment)
static unsafe byte * GetPointerToFirstInvalidByte(byte *pInputBuffer, int inputLength, out int utf16CodeUnitCountAdjustment, out int scalarCountAdjustment)
static unsafe OperationStatus TranscodeToUtf8(char *pInputBuffer, int inputLength, byte *pOutputBuffer, int outputBytesRemaining, out char *pInputBufferRemaining, out byte *pOutputBufferRemaining)
static unsafe OperationStatus TranscodeToUtf16(byte *pInputBuffer, int inputLength, char *pOutputBuffer, int outputCharsRemaining, out byte *pInputBufferRemaining, out char *pOutputBufferRemaining)
static unsafe OperationStatus ToUtf16(ReadOnlySpan< byte > source, Span< char > destination, out int bytesRead, out int charsWritten, bool replaceInvalidSequences=true, bool isFinalBlock=true)
Definition Utf8.cs:54
static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
static void ThrowArgumentNullException(string name)
T[] ToArray()
Definition Span.cs:291
static OperationStatus DecodeFromUtf8(ReadOnlySpan< byte > source, out Rune result, out int bytesConsumed)
Definition Rune.cs:202