public virtual void WriteString(string s) { var buf = SharedPool <byte> .Rent(Encoding.UTF8.GetByteCount(s)); try { var numberOfBytes = Encoding.UTF8.GetBytes(s, 0, s.Length, buf, 0); WriteBinary(buf, 0, numberOfBytes); } finally { SharedPool <byte> .Return(buf); } }
public override void WriteString(string str) { var buf = SharedPool <byte> .Rent(Encoding.UTF8.GetByteCount(str)); try { var numberOfBytes = Encoding.UTF8.GetBytes(str, 0, str.Length, buf, 0); Int32ToVarInt((uint)numberOfBytes, ref PreAllocatedVarInt); Trans.Write(PreAllocatedVarInt.bytes, 0, PreAllocatedVarInt.count); Trans.Write(buf, 0, numberOfBytes); } finally { SharedPool <byte> .Return(buf); } }