I have an HDF5 file with a fixed-length dataset containing fixed-length strings. Each string contains a null terminator somewhere in it, which other languages (e.g. Python, C, etc) understand marks the end of the string, and that characters beyond the null terminator are invalid and shouldn't be read out. But matlab's h5read function doesn't seem to understand this; it always gives me the entire string, including any junk characters that exist past the null-terminated part.
I can't seem to find an obvious function for removing elements after the null terminator, but it feels like this should exist. As an example, here's what one of my strings might look like:
['actual string' double(0) 'junk characters after null termination']
Is there a function that will trim off everything after the null terminator, or do I just need to do it myself? It should be easy to write, but I'd like to use a preexisting Matlab function if one exists. Something like this would work, but feels hacky/ugly:
x = x(1:find(x == 0, 1) - 1)