Protocol message had invalid UTF-8 (C++ to Java)

2,919 views
Skip to first unread message

robi...@e2eservices.co.uk

unread,
Feb 26, 2018, 8:54:31 AM2/26/18
to Protocol Buffers
Hello,

I'm hoping someone can help me out a bit here..

I've developed a C++ GRPC server (Question is protobuf specific though), that talks with a Java client. The C++ server takes data from an older C++ API and converts it to protobuf and then uses GRPC to send the data.

However it appears that there may be a bug in the older API and i'm occasionally being sent garbage in some char*, which when they get to java result in an Protocol message had invalid UTF-8.

It seems slightly odd that on the C++ side the protobuf is happy to accept and encode invalid data, but the Java side throws an exception.

Is there anyway from the C++ side to validate the messages strings before they are sent. I've noticed if i convert the message to JSON the strings just stop at the first invalid character they reach. I looked at trying to find a simple UTF8 validation in C++ but not had much luck with this (Sorry C++ is really noy my main language)

Developing in Visual Studio 2017 with C++11 support

Thanks,
Robin

Feng Xiao

unread,
Feb 26, 2018, 2:56:37 PM2/26/18
to robi...@e2eservices.co.uk, Protocol Buffers

Developing in Visual Studio 2017 with C++11 support

Thanks,
Robin

--
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 post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

robi...@e2eservices.co.uk

unread,
Feb 27, 2018, 3:11:00 AM2/27/18
to Protocol Buffers
Thanks, will give that a shot
Reply all
Reply to author
Forward
0 new messages