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

Method WriteLatin1

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

Source from the content-addressed store, hash-verified

114 }
115
116 private static void WriteLatin1(WriteContext context, string value)
117 {
118 int byteLength = value.Length;
119 if (byteLength == 0)
120 {
121 context.Writer.WriteUInt8((byte)ForyStringEncoding.Latin1);
122 return;
123 }
124
125 ulong header = ((ulong)byteLength << 2) | (ulong)ForyStringEncoding.Latin1;
126 Span<byte> headerBuf = stackalloc byte[MaxVarUInt36SmallBytes];
127 int headerBytes = EncodeVarUInt36Small(headerBuf, header);
128 Span<byte> destination = context.Writer.GetSpan(headerBytes + byteLength);
129 headerBuf.Slice(0, headerBytes).CopyTo(destination);
130 int written = Encoding.Latin1.GetBytes(value.AsSpan(), destination.Slice(headerBytes));
131 context.Writer.Advance(headerBytes + written);
132 }
133
134 private static void WriteUtf8(WriteContext context, string value)
135 {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected