Fix length calculation error when using padding before strings

A format like `"xS"` where padding is used before a string fails when using `pack` or `calculateLength`. The `calculateLength` function incorrectly consumes a value from the array.