Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

与protobuf的兼容问题 #42

Closed
vcnt opened this issue Oct 26, 2014 · 1 comment
Closed

与protobuf的兼容问题 #42

vcnt opened this issue Oct 26, 2014 · 1 comment

Comments

@vcnt
Copy link

vcnt commented Oct 26, 2014

发现编码的结果跟protobuf不一致,生成的编码protobuf不能正常解析。

对于消息:
message test{
required string id = 1;
}

赋值:
test.id = "1"

pbc编码结果:
0d 0a 02 31 20

protobuf编码结果:
0a 01 31

@cloudwu
Copy link
Owner

cloudwu commented Oct 27, 2014

你用错了.

message test {
    required string id = 1;
}
local p = require "parser"
local pb = require "protobuf"

t = p.register "test.proto"

pack = pb.encode("test", { id = "1" })

print(pack:gsub(".",  function(c) return string.format("%02x ", string.byte(c)) end))

输出

0a 01 31 3

@cloudwu cloudwu closed this as completed Oct 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants