Exemplo n.º 1
0
 public void WriteString(String v)
 {
     byte[] data = Coding.GetUtf8Coding().GetBytes(v);
     write.Write((byte)data.Length);
     write.Write((byte)0);
     write.Write(data);
     write.Write((byte)0);
 }
Exemplo n.º 2
0
        public String ReadString()
        {
            if (this.IsComplete(sizeof(byte)))
            {
                return("");
            }
            byte nLen = read.ReadByte();
            byte hi_  = read.ReadByte();

            if (hi_ > 0)
            {
                nLen = (byte)MAKEWORD(nLen, hi_);
            }
            if (this.IsComplete(nLen))
            {
                return("");
            }
            byte[] buf = read.ReadBytes(nLen);
            read.ReadByte(); //补位
            return(Coding.GetUtf8Coding().GetString(buf));
        }