/// <summary>Writes a char encoded in UTF-8</summary>
 public static void WriteChar(ref SliceWriter writer, char value)
 {
     if (value == 0)
     {             // NUL => "00 0F"
         // note: \0 is the only unicode character that will produce a zero byte when converted in UTF-8
         writer.WriteByte4(FdbTupleTypes.Utf8, 0x00, 0xFF, 0x00);
     }
     else if (value < 0x80)
     {             // 0x00..0x7F => 0xxxxxxx
         writer.WriteByte3(FdbTupleTypes.Utf8, (byte)value, 0x00);
     }
     else if (value < 0x800)
     {             // 0x80..0x7FF => 110xxxxx 10xxxxxx => two bytes
         writer.WriteByte4(FdbTupleTypes.Utf8, (byte)(0xC0 | (value >> 6)), (byte)(0x80 | (value & 0x3F)), 0x00);
     }
     else
     {             // 0x800..0xFFFF => 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
         // note: System.Char is 16 bits, and thus cannot represent UNICODE chars above 0xFFFF.
         // => This means that a System.Char will never take more than 3 bytes in UTF-8 !
         var tmp = Encoding.UTF8.GetBytes(new string(value, 1));
         writer.EnsureBytes(tmp.Length + 2);
         writer.UnsafeWriteByte(FdbTupleTypes.Utf8);
         writer.UnsafeWriteBytes(tmp, 0, tmp.Length);
         writer.UnsafeWriteByte(0x00);
     }
 }
 /// <summary>Writes a 64-bit UUID</summary>
 public static void WriteUuid64(ref SliceWriter writer, Uuid64 value)
 {
     writer.EnsureBytes(9);
     writer.UnsafeWriteByte(FdbTupleTypes.Uuid64);
     unsafe
     {
         byte *ptr = stackalloc byte[8];
         value.WriteTo(ptr);
         writer.UnsafeWriteBytes(ptr, 8);
     }
 }
 /// <summary>Writes a RFC 4122 encoded 128-bit UUID</summary>
 public static void WriteUuid128(ref SliceWriter writer, Uuid128 value)
 {
     writer.EnsureBytes(17);
     writer.UnsafeWriteByte(FdbTupleTypes.Uuid128);
     unsafe
     {
         byte *ptr = stackalloc byte[16];
         value.WriteTo(ptr);
         writer.UnsafeWriteBytes(ptr, 16);
     }
 }
        /// <summary>Writes a RFC 4122 encoded 16-byte Microsoft GUID</summary>
        public static void WriteGuid(ref SliceWriter writer, Guid value)
        {
            writer.EnsureBytes(17);
            writer.UnsafeWriteByte(FdbTupleTypes.Uuid128);
            unsafe
            {
                // UUIDs are stored using the RFC 4122 standard, so we need to swap some parts of the System.Guid

                byte *ptr = stackalloc byte[16];
                Uuid128.Write(value, ptr);
                writer.UnsafeWriteBytes(ptr, 16);
            }
        }