30 if ((num & (uint)(1 << (
int)(
codePoint >> 4))) == 0)
40 for (
int i = 32; i < 127; i++)
42 if (allowedBmpCodePoints.IsCharAllowed((
char)i))
44 ref
byte reference = ref
AsBytes[i & 0xF];
45 reference |= (byte)(1 << (i >> 4));
53 private unsafe fixed ulong Data[128];
58 byte* intPtr = stackalloc
byte[16];
63 for (
int i = 0; i < 128; i++)
77 span2.
Slice(num2).Clear();
78 for (
int num3 = num2 - 1; num3 >= 0; num3--)
80 uint num4 = span2[num3];
81 num = (num << 8) | num4;
84 Data[i] = num | ((ulong)(uint)num2 << 56);
114 if (forbidHtmlSensitiveCharacters)
119 for (
int i = 0; i < readOnlySpan.
Length; i++)
121 char value = readOnlySpan[i];
129 [Obsolete(
"FindFirstCharacterToEncode has been deprecated. It should only be used by the TextEncoder adapter.")]
135 [Obsolete(
"TryEncodeUnicodeScalar has been deprecated. It should only be used by the TextEncoder adapter.")]
144 numberOfCharactersWritten = 1;
153 numberOfCharactersWritten = num;
157 numberOfCharactersWritten = 0;
179 if (((
int)preescapedData & 0xFF00) == 0)
185 preescapedData >>= 8;
190 if ((
byte)(preescapedData >>= 8) != 0)
211 else if (!isFinalBlock &&
char.IsHighSurrogate(c))
244 num2 += charsWritten2;
245 num += charsWritten2;
271 num2 += (int)(preescapedData >> 56);
279 if ((
byte)(preescapedData >>= 8) != 0)
291 if (operationStatus != 0)
303 num2 += bytesWritten2;
304 num += bytesWritten2;
313 num += bytesConsumed2;
340 fixed (
byte* pData = data)
343 num = (int)(nuint)uIntPtr;
353 data = data.
Slice(num);
359 data = data.
Slice(bytesConsumed);
370 fixed (
char* ptr = data)
372 nuint num = (uint)data.
Length;
405 int num4 = (int)num2;
406 if (num4 == (
int)num)
430 Vector128<byte> value =
Vector128.
Create(1, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0);
433 if (lengthInBytes < 16)
437 nuint num2 = lengthInBytes & unchecked((nuint)(-16));
446 if (((uint)num3 & 0xFFFFu) != 0)
450 if ((num += 16) < num2)
458 if ((lengthInBytes & 8) != 0)
471 if ((lengthInBytes & 4) != 0)
478 if (((uint)num3 & 0xFu) != 0)
484 if ((lengthInBytes & 3) != 0)
502 Vector128<byte> value =
Vector128.
Create(1, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0);
505 if (lengthInChars < 16)
509 nuint num2 = lengthInChars & unchecked((nuint)(-16));
518 if (((uint)num3 & 0xFFFFu) != 0)
522 if ((num += 16) < num2)
530 if ((lengthInChars & 8) != 0)
543 if ((lengthInChars & 4) != 0)
550 if (((uint)num3 & 0xFu) != 0)
556 if ((lengthInChars & 3) != 0)
573 Vector128<byte> table =
Vector128.
Create(1, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0);
577 if (lengthInBytes < 16)
581 nuint num2 = lengthInBytes & unchecked((nuint)(-16));
591 if (num3 != ulong.MaxValue)
595 if ((num += 16) < num2)
606 if ((lengthInBytes & 8) != 0)
612 num3 = vector4.AsUInt64().ToScalar();
613 if (num3 != ulong.MaxValue)
619 if ((lengthInBytes & 4) != 0)
625 num3 = vector6.AsUInt32().ToScalar();
626 if (num3 != uint.MaxValue)
632 if ((lengthInBytes & 3) != 0)
647 Vector128<byte> table =
Vector128.
Create(1, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0);
651 if (lengthInChars < 16)
655 nuint num2 = lengthInChars & unchecked((nuint)(-16));
665 if (num3 != ulong.MaxValue)
669 if ((num += 16) < num2)
680 if ((lengthInChars & 8) != 0)
686 num3 = vector4.AsUInt64().ToScalar();
687 if (num3 != ulong.MaxValue)
693 if ((lengthInChars & 4) != 0)
699 num3 = vector6.AsUInt32().ToScalar();
700 if (num3 != uint.MaxValue)
706 if ((lengthInChars & 3) != 0)
static readonly bool IsLittleEndian
static int TrailingZeroCount(int value)
static unsafe void InitBlock(void *startAddress, byte value, uint byteCount)
static new bool IsSupported
static Vector128< byte > VectorTableLookup(Vector128< byte > table, Vector128< byte > byteIndexes)
static Vector128< byte > AddPairwise(Vector128< byte > left, Vector128< byte > right)
static unsafe Vector128< byte > LoadVector128(byte *address)
static Vector64< byte > And(Vector64< byte > left, Vector64< byte > right)
static Vector64< short > ShiftRightArithmetic(Vector64< short > value, byte count)
static Vector64< byte > ExtractNarrowingSaturateUnsignedLower(Vector128< short > value)
static unsafe Vector64< byte > LoadVector64(byte *address)
static Vector128< byte > ExtractNarrowingSaturateUnsignedUpper(Vector64< byte > lower, Vector128< short > value)
static Vector64< byte > CompareTest(Vector64< byte > left, Vector64< byte > right)
static Vector128< byte > Create(byte value)
static unsafe Vector128< byte > CreateScalarUnsafe(byte value)
static Vector128< T > Zero
static unsafe Vector128< sbyte > LoadVector128(sbyte *address)
static unsafe Vector128< double > LoadScalarVector128(double *address)
static int MoveMask(Vector128< sbyte > value)
static Vector128< sbyte > CompareEqual(Vector128< sbyte > left, Vector128< sbyte > right)
static Vector128< byte > PackUnsignedSaturate(Vector128< short > left, Vector128< short > right)
static Vector128< byte > And(Vector128< byte > left, Vector128< byte > right)
static Vector128< short > ShiftRightLogical(Vector128< short > value, Vector128< short > count)
static Vector128< sbyte > Shuffle(Vector128< sbyte > value, Vector128< sbyte > mask)
static new bool IsSupported
readonly AllowedBmpCodePointsBitmap _allowedBmpCodePoints
OperationStatus Encode(ReadOnlySpan< char > source, Span< char > destination, out int charsConsumed, out int charsWritten, bool isFinalBlock)
unsafe bool TryEncodeUnicodeScalar(int unicodeScalar, char *buffer, int bufferLength, out int numberOfCharactersWritten)
readonly AsciiPreescapedData _asciiPreescapedData
unsafe nuint GetIndexOfFirstCharToEncodeSsse3(char *pData, nuint lengthInChars)
unsafe nuint GetIndexOfFirstByteToEncodeAdvSimd64(byte *pData, nuint lengthInBytes)
unsafe int GetIndexOfFirstByteToEncode(ReadOnlySpan< byte > data)
unsafe int GetIndexOfFirstCharToEncode(ReadOnlySpan< char > data)
readonly ScalarEscaperBase _scalarEscaper
unsafe int FindFirstCharacterToEncode(char *text, int textLength)
OperationStatus EncodeUtf8(ReadOnlySpan< byte > source, Span< byte > destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock)
OptimizedInboxTextEncoder(ScalarEscaperBase scalarEscaper, in AllowedBmpCodePointsBitmap allowedCodePointsBmp, bool forbidHtmlSensitiveCharacters=true, ReadOnlySpan< char > extraCharactersToEscape=default(ReadOnlySpan< char >))
unsafe nuint GetIndexOfFirstByteToEncodeSsse3(byte *pData, nuint lengthInBytes)
readonly AllowedAsciiCodePoints _allowedAsciiCodePoints
bool IsScalarValueAllowed(Rune value)
void _AssertThisNotNull()
unsafe nuint GetIndexOfFirstCharToEncodeAdvSimd64(char *pData, nuint lengthInChars)
int EncodeUtf16(Rune value, Span< char > destination)
int EncodeUtf8(Rune value, Span< byte > destination)
static bool TryWriteUInt64LittleEndian(Span< byte > span, int offset, ulong value)
static bool IsAsciiCodePoint(uint value)
ReadOnlySpan< T > Slice(int start)
Span< T > Slice(int start)
unsafe void ForbidChar(char value)
unsafe readonly bool IsCharAllowed(char value)
unsafe void ForbidUndefinedCharacters()
unsafe readonly bool IsCodePointAllowed(uint value)
void ForbidHtmlCharacters()
unsafe void PopulateAllowedCodePoints(in AllowedBmpCodePointsBitmap allowedBmpCodePoints)
unsafe readonly bool IsAllowedAsciiCodePoint(uint codePoint)
Vector128< byte > AsVector
unsafe fixed byte AsBytes[16]
unsafe void PopulatePreescapedData(in AllowedBmpCodePointsBitmap allowedCodePointsBmp, ScalarEscaperBase innerEncoder)
unsafe readonly bool TryGetPreescapedData(uint codePoint, out ulong preescapedData)
static bool IsControl(Rune value)
static OperationStatus DecodeFromUtf8(ReadOnlySpan< byte > source, out Rune result, out int bytesConsumed)
static Rune ReplacementChar
static bool TryCreate(char ch, out Rune result)
bool TryEncodeToUtf8(Span< byte > destination, out int bytesWritten)
bool TryEncodeToUtf16(Span< char > destination, out int charsWritten)