Skip to content

Java & Golang: Best way for dealing with binary data? #488

Closed
@meyerdan

Description

@meyerdan

In our messages we are definiting a fields which contian binary data. For this we are using the varDataEncoding composite defined as follows.

    <composite name="varDataEncoding">
      <type name="length" primitiveType="uint16" />
      <type name="varData" primitiveType="uint8" length="0" characterEncoding="UTF-8" />
    </composite>

My questions go to the "characterEncoding" attribute:

  • When we use this with the Java Code generator we get methods generated which allow us to access the data both as a String but also as a binary buffer / array ... This is fine, we do not need the String representation so we simply do not call that method.

  • In the Golang generator, however, when enabling the range check, the decoder throws an error, complaining that the bytes we put into the field are not utf8 valid.

We need some guidance on how to deal with this:

  • should we define the protocol differently if we have binary content?
  • or, is this a bug in the golang generator?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions