Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when parse a message, got an error field #60

Open
violetdeng opened this issue Oct 31, 2016 · 0 comments
Open

when parse a message, got an error field #60

violetdeng opened this issue Oct 31, 2016 · 0 comments

Comments

@violetdeng
Copy link

violetdeng commented Oct 31, 2016

I'm struggling with the bytes or utf-8 problem, the value of nick attribute is "nihao_1", while to array it changes to "1", I can't find out the reason
PHP version is 5.4
here's my codes

message server_user_account_t{
required string source_number = 1;
required bytes nick = 2;
required uint32 server_id = 3;
optional uint32 sex = 4;
}

$body = server_user_account_t::parseFromString($str);
var_dump($body);

the print message is

object(hy\protobuf\server_user_account_t)#25 (4) {
    ["source_number":protected]=>
    string(9) "757559966"
    ["nick":protected]=>
    string(7) "nihao_1"
    ["server_id":protected]=>
    string(1) "1"
    ["sex":protected]=>
    NULL
  }
$body = $body->toArray();
var_dump($body);

the print message is

array(3)` {
  ["source_number"]=>
  string(9) "757559966"
  ["nick"]=>
  int(0)
  ["server_id"]=>
  int(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant