Open/create HDF5 files with non-UTF8 chars such as Shift-JIS

Hi, I’m updating the HDF5 C library that is used within IDL. We’re going from HDF5 v1.10.5 to v1.14.3. It looks like in version 1.12 support was added on Windows systems for UTF-8 filenames when opening/creating HDF5 files. This is fantastic - thanks for doing that - it seems to work great.

However, there doesn’t seem to be a fallback case for non-UTF8 filenames. Looking in H5system.c, it tries to use MultiByteToWideChar to convert from UTF8 to UTF-16. If this fails then it just bails and doesn’t open the file. We’ve got a Japanese Windows test machine that uses Shift-JIS as its native encoding. For filenames with ASCII characters everything is fine. But if the filename (or folder) has any Japanese characters then H5Fcreate and H5fopen fail miserably.

I could workaround this with some complicated pre-conversion, but I have no idea what codepage the filenames might be using. In our other wrapper code (for reading TIFF or PNG files), we try the MultiByteToWideChar and if it fails, then we just open up the file using the normal Windows non-wide _open. This works fine for Shift-JIS.

Am I missing something, either in compiling the library or my usage?

If not, it would be great if the HDF5 C library could follow a similar pattern: try MultiByteToWideChar (with CP_UTF8) first, and then rather than failing completely, fallback to simply calling _open rather than _wopen.

Thanks!
-Chris

1 Like

Hi, I’m using IDL 8.9.0 and could confirm that it uses 1.10.5:

IDL> HELP, ‘hdf5’, /DLM
HELP, ‘hdf5’, /DLM
** HDF5 - IDL Hierarchical Data Format 5 (HDF5) support DLM (not loaded)
Version: hdf5 1.10.5, szip 2.1, zlib 1.2.13, Build Date: APR 17 2023, Source: Harris
Geospatial Solutions, Inc.
Path: /usr/local/harris/envi57/idl89/bin/bin.linux.x86_64/idl_hdf5.so

I’m quite excited to hear that you’re working on IDL update for HDF5.
Such update will be very useful for IDL users.

I’m curious about the planned target version (e.g., 9.x) of IDL that will use HDF5 1.14.3.
I checked What’s New in IDL 9.0 (nv5geospatialsoftware.com) but it doesn’t mention what version of HDF5 is being used in 9.0.
Does IDL 9.0 also use 1.10.5?

Yes, IDL 8.9 and 9.0 use HDF5 1.10.5. The next IDL version (9.1) will use 1.14.3.
Thanks for your interest!
Chris
NV5 Geospatial

1 Like

Does this fix solve your problem?