simple-binary-encoding icon indicating copy to clipboard operation
simple-binary-encoding copied to clipboard

How to print an int8 field as a char in decoder.appendTo() method?

Open pcdv opened this issue 4 months ago • 2 comments

Hi,

Let's suppose a field can have values 'A', 'B', 'C' and is encoded as a int8, uint8 or char on the wire.

Even when setting semanticType="char", the string representation of the message always shows the ordinal value of the field, e.g. 65 instead of 'A'.

Have I missed anything? Otherwise, would it be a good addition to allow printing those fields as chars instead of byte / short?

Thanks

pcdv avatar Sep 08 '25 09:09 pcdv

Hi,

Let's suppose a field can have values 'A', 'B', 'C' and is encoded as a int8, uint8 or char on the wire.

Even when setting semanticType="char", the string representation of the message always shows the ordinal value of the field, e.g. 65 instead of 'A'.

Have I missed anything? Otherwise, would it be a good addition to allow printing those fields as chars instead of byte / short?

Thanks

abrahem79 avatar Sep 14 '25 11:09 abrahem79

The PR above prints foo='A' instead of foo=65, except when value is not printable, in which case it prints e.g. foo=\0 (numeric value preceded by \).

Open to suggestions

pcdv avatar Sep 25 '25 11:09 pcdv