Le 23/08/2021 à 17:52, David Li a écrit :
Another way forward might be to relax the value type to [byte], but also 
require implementations to null-terminate binary values regardless. The C++ 
Flatbuffers implementation does this already [1] (though not the Java one [2]). 
Old implementations validating UTF8-ness would still be unable to read anything 
with binary metadata (which is the case they're already in), but 
implementations just validating for null-termination would continue to work. 
And again, I believe this is in-spec for Flatbuffers since string lengths don't 
include the null terminator.

[1]: 
https://github.com/google/flatbuffers/blob/273f6084e55285e26ff8b4cdd55a9c0e2d9a48b7/include/flatbuffers/flatbuffers.h#L1612-L1670
[2]: 
https://github.com/google/flatbuffers/blob/273f6084e55285e26ff8b4cdd55a9c0e2d9a48b7/java/com/google/flatbuffers/FlatBufferBuilder.java#L594-L637
Though it seems we could emulate C++ here by calling addByte(0) ourselves 
before createByteVector.

Would that allow for both forwards and backwards compatibility when the metadata is valid UTF8?

Regards

Antoine.

Reply via email to