public void WriteByteString(string s, int tag) { Reserve(10 + s.Length); byte[] by = HexUtil.HexStr2Bytes(s); if (by.Length > 255) { WriteHead(TarsStructBase.STRING4, tag); buf.WriteInt(by.Length); buf.WriteBytes(by); } else { WriteHead(TarsStructBase.STRING1, tag); buf.WriteByte(by.Length); buf.WriteBytes(by); } }
public void WriteStringByte(string s, int tag) { byte[] by = HexUtil.HexStr2Bytes(s); Reserve(10 + by.Length); if (by.Length > 255) { // 长度大于255,为String4类型 WriteHead(TarsStructBase.STRING4, tag); buf.WriteInt(by.Length); buf.WriteBytes(by); } else { // 长度小于255,位String1类型 WriteHead(TarsStructBase.STRING1, tag); buf.WriteByte(by.Length); buf.WriteBytes(by); } }