On Jan 13, 2:23 am, 飞 杨 youngphy.y...@dianping.com wrote:
Dear sir,
I found, in the protocolbuf int encode, the byte 0xFF may appear, then
how can i distinguish the EOS and the business -1, the two both are -1
when use the inputstream.read()..
Pay closer attention to the definition of
As Adam said, -1 has a representation that is not just a single 0xFF. To
decode a varint, you have to read the bytes until the most significant bit
is 0. (See
http://code.google.com/apis/protocolbuffers/docs/encoding.html#varints)
Note that int32 values are sign-extended for wire compatibility