[BUG] Writing a string does not include NULL terminator

Hello!

To reproduce:

  1. Compile and run attached
    test727.c (730 Bytes)

  2. It worked just fine, as confirmed by h5dump test.h5:

HDF5 "test.h5" {
GROUP "/" {
   ATTRIBUTE "key" {
      DATATYPE  H5T_STRING {
         STRSIZE 4;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
      DATA {
      (0): "123"
      }
   }
}
}

However according to docs, it should have failed:

The size set for a string datatype should include space for the null-terminator character, otherwise it will not be stored on (or retrieved from) disk

It is proposed to fix incorrect/inaccurate description.

Originally reported in Writing a string does not include NULL terminator · Issue #727 · h5py/h5py · GitHub.

Best wishes,
Andrey Paramonov

Hello!

Any chance getting this into JIRA?

Best wishes,
Andrey Paramonov

We will fix documentation. Only size-1 number of characters will be stored, so library behaves correctly. If you change size to 5, you’ll see 1234 string.

Thanks for reporting!

Elena