protobuf-net and c++ protocol buffer missing line feeds.

91 views
Skip to first unread message

rui

unread,
Mar 7, 2012, 8:00:59 PM3/7/12
to prot...@googlegroups.com
Hi,
I am having problem deserializing messages on c++ side

From c#, i do this:

 using (MemoryStream ms = new MemoryStream())
            {
               Serializer.Serialize(ms, instance);

               return ms.ToArray();
            }

This is the class for instance parameter in protocol buffer.
message init_message
{
   optional string subject = 1;
   optional string html_body = 2;
   optional string plain_body = 3;
}

on c++ side, i do, where msg is the byte array passed
entity.ParseFromArray(msg.get_data(), msg.data_length);

but it somehow drops all the line feeds and carriage returns \r\n in the transition for all the member variables.

What could be the reason?

Thanks,
rui




Marc Gravell

unread,
Mar 8, 2012, 1:55:33 AM3/8/12
to rui, prot...@googlegroups.com
Well, protobuf-net certainly includes them (it just does a simple UTF-8 conversion, nothing more), and I'm pretty sure the C++ side will be handling them fine.

My guess would be that they are being lost in your code with whatever file / network handling you have in place. In particular, any code that treats the files as text rather than binary, or does automatic line ending conversions (which again, is text-based). Another guess would be that the two machines have different line-ending expectations, and simply: they are **there**, but aren't showing. I might expect this when loading a linux file on Windows, for example.

Marc

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/jen3HyN2pIQJ.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.



--
Regards,

Marc

rui

unread,
Mar 8, 2012, 7:12:09 AM3/8/12
to prot...@googlegroups.com, rui
Thanks, i confirmed everything is fine after comparing the data using the serialize/deserialize on both sides.
Marc

To unsubscribe from this group, send email to protobuf+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.



--
Regards,

Marc
Reply all
Reply to author
Forward
0 new messages