To get Unicode path support on Windows, I make a custom HDF5 build. I make
two changes to the H5win32defs.h file.
First, I add a static function that converts UTF8 to Windows UCS2:
static int utf8open(const char* filename, int oflag, int pmode)
// In order to open files with Unicode paths, Windows requires that I
call the _wopen function
// rather than pass UTF8 to _open. Therefore, this function will first
translate the filename
// to UCS2.
int cch = MultiByteToWideChar(
if (0 == cch)
// File or path not found is the most reasonable of the documented
error codes to return
// from this function if there is a text encoding error in the
errno = ENOENT;
// _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL
transformations when performing
// I/O. _O_NOINHERIT must be set to prevent child processes inheriting
return _wopen(wfilename, oflag | _O_BINARY | _O_NOINHERIT, pmode);
Second, I change the #define HDopen in that file to use my function:
#define HDopen(S,F,M) utf8open(S,F|_O_BINARY,M)
Before calling HDF5 functions that take file paths, I also have to convert
the UCS2 paths I get from Windows API calls to UTF8. It’s kind of
inconvenient, but so far I haven’t had any problems passing the
UTF8-encoded paths through HDF5 using this technique, and the required
changes are not very invasive.
*From:* Hdf-forum [mailto:email@example.com] *On
Behalf Of *Elvis Stansvik
*Sent:* Monday, July 4, 2016 3:40 AM
*Subject:* [Hdf-forum] Cross-platform Unicode filename support?
Anyone know what happened with
? That thread ended with Quincey saying
"Seems like a reasonable idea. I've filed a bug in our bug tracker
and it'll get prioritized with the other things there, but we'd be
happy to accept a well-tested patch from the community also."
Was it ever worked on / brought up within the HDF5 Group?
Thanks in advance,
PS. Would love if there was a public bug tracker. DS.
Hdf-forum is for HDF software users discussion.