[hdf-forum] Unicode filenames on Windows?
Francesc Alted
faltet at pytables.org
Wed Jun 3 04:32:39 EDT 2009
A Wednesday 03 June 2009 05:26:25 Andrew Collette escrigué:
> Hello,
>
> Does anyone know how to open or create an HDF5 file on Windows with a
> Unicode name? From what I've been able to determine, it looks like
> it's possible to use file names which contain bytes > 127, and
> interpret them according to locale settings. However, there doesn't
> seem to be any mechanism for generic (multi-byte) Unicode file names
> like those supported by NTFS. Is this possible in HDF5?
I don't know for sure how to do that in pure C, but if you are using Python
(and I think that's the case), you can encode the file name using the
underlying filesystem encoding. The next function:
def encode_filename(filename):
"""Return the encoded filename in the filesystem encoding."""
if type(filename) is unicode:
encoding = sys.getfilesystemencoding()
encname = filename.encode(encoding)
else:
encname = filename
return encname
works well on every filesystem that I've tested (including NTFS).
Once you've got the encode file name, it is just a matter to pass it to the
relevant HDF5 function (H5Fcreate/H5Fopen).
Hope that helps,
--
Francesc Alted
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe at hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe at hdfgroup.org.
More information about the Hdf-forum
mailing list