MCPcopy Create free account
hub / github.com/apache/fory / WriteUtf16

Method WriteUtf16

csharp/src/Fory/StringSerializer.cs:153–163  ·  view source on GitHub ↗
(WriteContext context, string value)

Source from the content-addressed store, hash-verified

151 }
152
153 private static void WriteUtf16(WriteContext context, string value)
154 {
155 int byteLength = checked(value.Length * 2);
156 ulong header = ((ulong)byteLength << 2) | (ulong)ForyStringEncoding.Utf16;
157 Span<byte> headerBuf = stackalloc byte[MaxVarUInt36SmallBytes];
158 int headerBytes = EncodeVarUInt36Small(headerBuf, header);
159 Span<byte> destination = context.Writer.GetSpan(headerBytes + byteLength);
160 headerBuf.Slice(0, headerBytes).CopyTo(destination);
161 int written = Encoding.Unicode.GetBytes(value.AsSpan(), destination.Slice(headerBytes));
162 context.Writer.Advance(headerBytes + written);
163 }
164
165 private static int EncodeVarUInt36Small(Span<byte> destination, ulong value)
166 {

Callers

nothing calls this directly

Calls 4

GetSpanMethod · 0.80
SliceMethod · 0.80
AdvanceMethod · 0.80
CopyToMethod · 0.45

Tested by

no test coverage detected