SUMMARY Okteta currently supports fixed-length and character-terminated strings. Arrays OTOH can have a variable length dependent on a previously parsed primitive value. It would be really nice to have this option for the maxCharCount and maxByteCount arguments as well. This would allow parsing of strings stored as length+stringdata without null-terminator. Workarounds: Use an array instead and look at the string value byte by byte.
Alex, would you remember a reason besides no spare time resources that maxCharCount and maxByteCount could not be also optionally scripted properties? Would look into this otherwise in the next weeks. FTR, as another work-around (though resulting in data reparsing) one can use the updateFunc, starting with maxCharCount or maxByteCount set to 0 and then have the value updated from that type-wide generic function. E.g. with JS: var obj = struct({ length: uint16(), data: string("utf-8").set({ maxByteCount: 0, updateFunc: function() { this.maxByteCount = this.parent.length.value; } }) }); or with XML <struct name="variablelengthstring"> <primitive name="length" type="uint16" /> <string name="data" encoding="utf-8" maxByteCount="0" updateFunc="function() { this.maxByteCount = this.parent.length.value; }"> </struct>