Closed palyamate closed 2 years ago
Thanks for your feedback.
Your encoding 0148044A 6F686E03 446F65
does not make really sense, as it looks shorter than the firstname / lastname strings, which are unconstrained UTF8, meaning each character is encoded on at least 1 byte.
You can also see with the asn1playground that decoding this buffer does not work:
D0081S: End of input reached before message was fully decoded; check field 'firstname' of PDU #1.
value: D0081S: End of input reached before message was fully decoded; check field 'firstname' of PDU #1.
S0014E: Printing of PER details failed with the return code '4'.
The output may be truncated.
Oh, sorry, I copied the wrong structure and bytes...
This is the encoded version:
48044A6F 686E0344 6F65
And this is the correct JSON:
{
"age": 72,
"firstname": "John",
"lastname": "Doe"
}
Encoding to the file 'data.uper' using PER UNALIGNED encoding rule...
Person SEQUENCE [fieldcount (not encoded) = 3]
age INTEGER [length (not encoded) = 0.7]
72
firstname UTF8String [length = 4.0]
0x4a6f686e
lastname UTF8String [length = 3.0]
0x446f65
Total encoded length = 9.7
Encoded successfully in 10 bytes:
900894DE D0DC0688 DECA
You are failing somewhere with the value you want to encode or the buffer you have encoded. Please verify you data before submitting further information / issue.
I got encode/decode error on a data, which I can't share, because it's confidential. I was pretty sure it was with the UTF8String length encoding when I debugged it. I tried to reproduce it with a minimal reproduction, but it seems I failed to do it with this example. I will close this issue for now, and I will reopen it or open another issue, when I can create a better example.
I used this scheme:
I encoded this on this:
and the UPER encoded version:
0148044A 6F686E03 446F65
I compiled this with _pycrateasn1compile.py and used the.from_uper
function of the Person. I got this error:The standard is here. The 10.9 says something about the string lenght encoding.