public static void WritePrimitive(IoBuffer buffer, string value) { if (value == null) { WritePrimitive(buffer, (uint)0); return; } var encoding = new UTF8Encoding(false, true); int len = encoding.GetByteCount(value); WritePrimitive(buffer, (uint)len + 1); var buf = new byte[len]; encoding.GetBytes(value, 0, value.Length, buf, 0); buffer.Write(buf, 0, len); }