I am trying to decode a BER encoded file using a specification which also specifies several fields as being of BCDString type.
The specification provides the following comments for this type:
-- The BCDString data type (Binary Coded Decimal String) is used to represent
-- several digits from 0 through 9, a, b, c, d, e.
-- Two digits are encoded per octet. The four leftmost bits of the octet represent
-- the first digit while the four remaining bits represent the following digit.
-- A single f must be used as a filler when the total number of digits to be
-- encoded is odd.
-- No other filler is allowed.
And an example of one of the fields as it is in the specification:
Imsi ::= [APPLICATION 129] BCDString --(SIZE(3..8))
The provides SIZE value differs per field.
I am currently using the following code to decode these fields in my own script:
for char in field_value:
for val in (char >> 4, char & 0xF):
if val == 0xF:
return
yield str(val)
Let me know if this is enough information to go on, if not, which information do you need?
Hi,
I am trying to decode a BER encoded file using a specification which also specifies several fields as being of BCDString type. The specification provides the following comments for this type:
-- The BCDString data type (Binary Coded Decimal String) is used to represent -- several digits from 0 through 9, a, b, c, d, e. -- Two digits are encoded per octet. The four leftmost bits of the octet represent -- the first digit while the four remaining bits represent the following digit. -- A single f must be used as a filler when the total number of digits to be -- encoded is odd. -- No other filler is allowed.
And an example of one of the fields as it is in the specification: Imsi ::= [APPLICATION 129] BCDString --(SIZE(3..8))
The provides SIZE value differs per field.
I am currently using the following code to decode these fields in my own script:
Let me know if this is enough information to go on, if not, which information do you need?
Cheers, Jelmoh