J8583 LLLLBIN and LLLLVAR produces the different length padding result

413 views Asked by At

LLLLVAR and LLLLBIN produces different length produced from the same input.

Tried to pass in the value "6832" into the same IsoMessage object, however, LLLLVAR returns "00046382", while LLLLBIN returns "000836333832".

Sample of the source code as below:

msg.setValue(60, "6832".toByteArray(Charsets.US_ASCII), IsoType.LLLLBIN, 10)//encodes to 000836333832 
msg.setValue(60, "6832", IsoType.LLLLVAR, 10) //encodes to 00046382 

I though both should return 0004, why are both results different?

1

There are 1 answers

3
Chochos On

When you encode ISO messages as text, the LxBIN fields encode their data in hex, and so the size is double what you'd expect. However, the decoder decodes the hex data and gives you a byte array when parsing.

LxVAR and LxBIN fields only have the same length when the whole message is encoded using binary formatting.