Getting NULL character in string when using SerializeToString

23 views
Skip to first unread message

Saurabh Grade

unread,
Sep 2, 2020, 3:33:15 PM9/2/20
to Protocol Buffers
Hi,

Using SerializeToString to serialize a protobuf object and getting NULL character in serialized string.
What could be the reason of this?
How can we avoid NULL characters in serialized string?

Please let me know if more details are needed.

Thanks in advance.

Thanks and Regards,
Saurabh Grade

Adam Cozzette

unread,
Sep 2, 2020, 5:48:31 PM9/2/20
to Saurabh Grade, Protocol Buffers
There is no practical way to avoid having zero bytes in the serialized message. For example, zero-valued integer fields will show up as zero bytes in the serialized message. If you need the serialized form to contain only printable characters, you could try base64-encoding it as an additional step.

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/fc6f5c69-0538-43df-ad02-266539778b81n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages