33 fixed (
byte* ptr = &
buffer[0])
35 byte* ptr2 = ptr +
start;
63 ptr[1] = (byte)(
value >> 8);
71 *ptr = (byte)(
value >> 8);
80 *ptr = (byte)(
value >> 24);
81 ptr[1] = (byte)(
value >> 16);
82 ptr[2] = (byte)(
value >> 8);
92 ptr[1] = (byte)(
value >> 8);
93 ptr[2] = (byte)(
value >> 16);
94 ptr[3] = (byte)(
value >> 24);
106 value.GetBits(out var isNegative, out var scale, out var low, out var mid, out var high);
107 buffer.WriteByte(
start, (
byte)(scale | (isNegative ? 128u : 0u)));
117 byte* ptr = (
byte*)(&
value);
118 uint num = *(uint*)ptr;
120 ptr2[1] = (byte)(num >> 8);
121 ptr2[2] = (byte)(num >> 16);
122 ptr2[3] = (byte)(num >> 24);
123 ushort num2 = *(ushort*)(ptr + 4);
124 ptr2[4] = (byte)num2;
125 ptr2[5] = (byte)(num2 >> 8);
126 ushort num3 = *(ushort*)(ptr + 6);
127 ptr2[6] = (byte)num3;
128 ptr2[7] = (byte)(num3 >> 8);
143 fixed (
byte* ptr2 = &
buffer[0])
145 byte* ptr3 = ptr2 +
start;
148 while (charPtr < ptr)
150 *(ptr3++) = (
byte)(*(charPtr++));
154 while (charPtr < ptr)
156 char c = *(charPtr++);
164 *ptr3 = (byte)(((uint)((int)c >> 6) & 0x1Fu) | 0xC0u);
165 ptr3[1] = (byte)((c & 0x3Fu) | 0x80u);
174 int num2 = *(charPtr++);
175 int num3 = (num - 55296 << 10) + num2 - 56320 + 65536;
176 *ptr3 = (byte)(((uint)(num3 >> 18) & 7u) | 0xF0u);
177 ptr3[1] = (byte)(((uint)(num3 >> 12) & 0x3Fu) | 0x80u);
178 ptr3[2] = (byte)(((uint)(num3 >> 6) & 0x3Fu) | 0x80u);
179 ptr3[3] = (byte)(((uint)num3 & 0x3Fu) | 0x80u);
183 if (!allowUnpairedSurrogates)
188 *ptr3 = (byte)(((uint)((int)c >> 12) & 0xFu) | 0xE0u);
189 ptr3[1] = (byte)(((uint)((int)c >> 6) & 0x3Fu) | 0x80u);
190 ptr3[2] = (byte)((c & 0x3Fu) | 0x80u);
198 fixed (
char* str2 =
str)
236 if (num + num2 > byteLimit)
238 ptr2 -= ((num2 < 4) ? 1 : 2);
249 return (uint)(c - 55296) <= 2047u;
254 return (uint)(c - 55296) <= 1023u;
259 return (uint)(c - 56320) <= 1023u;
265 if (start < 0 || start > bufferLength)
269 if (byteCount < 0 || byteCount > bufferLength -
start)
277 return characterCount * 2 + 1;
282 foreach (
char c
in str)
static bool IsLowSurrogateChar(int c)
static unsafe int GetUTF8ByteCount(char *str, int charCount, int byteLimit, out char *remainder)
static unsafe int GetUTF8ByteCount(char *str, int charCount)
static unsafe void WriteUInt32(this byte[] buffer, int start, uint value)
static unsafe void WriteDouble(this byte[] buffer, int start, double value)
static unsafe void WriteGuid(this byte[] buffer, int start, Guid value)
static void ValidateRange(int bufferLength, int start, int byteCount, string byteCountParameterName)
static unsafe void WriteUInt16(this byte[] buffer, int start, ushort value)
static unsafe void WriteUInt32BE(this byte[] buffer, int start, uint value)
const int SizeOfSerializedDecimal
static unsafe void WriteUInt16BE(this byte[] buffer, int start, ushort value)
static unsafe ImmutableArray< byte > ReadImmutableBytes(byte *buffer, int byteCount)
static unsafe void WriteBytes(this byte[] buffer, int start, byte value, int byteCount)
static unsafe void WriteSingle(this byte[] buffer, int start, float value)
static bool IsHighSurrogateChar(int c)
static unsafe void WriteUTF8(this byte[] buffer, int start, char *charPtr, int charCount, int byteCount, bool allowUnpairedSurrogates)
static bool IsSurrogateChar(int c)
static void WriteDecimal(this byte[] buffer, int start, decimal value)
static byte GetUserStringTrailingByte(string str)
static void WriteUInt64(this byte[] buffer, int start, ulong value)
static void WriteByte(this byte[] buffer, int start, byte value)
static unsafe int GetUTF8ByteCount(string str)
static int GetUserStringByteLength(int characterCount)
static unsafe byte[] ReadBytes(byte *buffer, int byteCount)
static readonly T[] Instance
static ImmutableArray< byte > DangerousCreateFromUnderlyingArray(ref byte[]? array)
static void ArgumentOutOfRange(string parameterName)
static void Copy(int[] source, int startIndex, IntPtr destination, int length)