Allow a user to define his/her own length field decoder

- Fixes #1960