Fix handling of string when packing
The size used for packing the string was wrong because it used the original string lenght rather than the encoded.
The size used for packing the string was wrong because it used the original string lenght rather than the encoded.