Actually, I was wrong, this code produces an empty string. The
following code serializes *something* which fails on the server side
on ParseFromString. Any ideas what I have to do to correctly serialize
this?


        private string Serialize(OrderProto proto)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                Serializer.Serialize<OrderProto>(stream, proto);
                stream.Seek(0, SeekOrigin.Begin);
                using (BinaryReader reader = new BinaryReader(stream,
Encoding.ASCII))
                {
                    char[] chars = new char[stream.Length];
                    for (int i = 0; i < stream.Length; i++)
                        chars[i] = reader.ReadChar();
                    return new string(chars);
                }
            }
        }

Thanks

On Apr 2, 1:04 pm, "test.f...@nomail.please" <test.f...@gmail.com>
wrote:
> It seems I was wrong in trying to use ASCII or UTF-8 encoding. This
> works.
>
>         private string Serialize(OrderProto proto)
>         {
>             using (MemoryStream stream = new MemoryStream())
>             {
>                 Serializer.Serialize<OrderProto>(stream, proto);
>                 using (StreamReader reader = new StreamReader(stream))
>                     return reader.ReadToEnd();
>             }
>         }
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to