Loading strings in binary mode broken


#1

It seems that contrary to the documentation that when loading string attributes in binary mode, the strings must be null terminated. You must also add an additional count to the number of bytes to account for this null. To use an example from the docs:

(Bytes 26-29) 3
30 D
31 o
32 e          

Should be:

(Bytes 26-29) 4
30 D
31 o
32 e
33 ␀

When the null termination is omitted, the load may appear to be successful, but occasionally strings returned by queries (via iquery) will have extra gibberish at the end. The easy way to tell is to apply the function strlen() to string attributes, and you can clearly see that the length of the string is one less than it should be. i.e. the string “Joe” will be strlen()==2, even though the full string is displayed. This mismatch leads me to wonder how it is stored, and if in fact null termination is enough to correct the problem.

I’d chalk this up to a documentation error, but it seems redundant to have both the length of a string recorded, and have it null terminated. But one thing you could do to clarify the documentation is to note that the string lengths are given in unsigned integers. It may seem obvious, but it is not clearly stated.