On the following example, from the encoding page 
(https://developers.google.com/protocol-buffers/docs/encoding) :
Strings

A wire type of 2 (length-delimited) means that the value is a varint 
encoded length followed by the specified number of bytes of data.

message Test2 {
  required string b = 2;
}

Setting the value of b to "testing" gives you:

12 07 74 65 73 74 69 6e 67

The red bytes are the UTF8 of "testing". The key here is 0x12 → tag = 2, 
type = 2. The length varint in the value is 7 and lo and behold, we find 
seven bytes following it – our string.

Isn't the first byte 18, instead of 12? 12 gives a tag=1, type=4, while 18 
gives the expected result of tag=2, type=2.

Regards,

Felipe

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to