Alexey Timanovsky
Alexey Timanovsky

Reputation: 567

ASCII safe serialization of protocol buffers

I need to pass Protocol Buffers structures as ASCII strings (actually UTF8 strings, but ASCII would also do). Is there any out of the box solution in C++ ?

Upvotes: 1

Views: 2243

Answers (2)

genpfault
genpfault

Reputation: 52083

If you want to be lazy you could always base64 the binary output.

Upvotes: 3

Jon Skeet
Jon Skeet

Reputation: 1500815

You should be able to use the TextFormat class with its Parse and Print functions. I can't remember offhand how that treats non-ASCII string fields, so you should check that, but it's the general support for text in Protocol Buffers. Various other platforms support the same format, so it's still portable.

Upvotes: 3

Related Questions