h5md-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [h5md-user] units module


From: Peter Colberg
Subject: Re: [h5md-user] units module
Date: Fri, 1 Nov 2013 11:13:55 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Felix, hi all,

On Thu, Oct 31, 2013 at 05:17:18PM +0100, Felix Höfling wrote:
> I made an effort to write down a specification for the units module
> to make progress. I took up Pierre's suggestion and added a list of
> units inspired by Mosaic and udunits2.

Thank you for working on the units module!

For the encoding, can we just go with UTF8, instead of both ASCII and UTF8?

The issue with encodings is that HDF5 does not support implicit
datatype conversion between ASCII and UTF8. So the reader needs to
specify the correct encoding when reading a "unit" attribute, which
is addressed in commit c065ace by the module attribute "encoding".

Since UTF8 is a superset of ASCII (characters 0-127), the only thing a
C or Fortran writer has to do to use UTF8 encoding is call H5Tset_cset
on the datatype, e.g.,

  hid_t dtype = H5Tcopy(H5T_C_S1);
  H5Tset_size(dtype, H5T_VARIABLE);
  H5Tset_cset(dtype, H5T_CSET_UTF8);

In Python the string needs to be in UTF8 encoding:

  dataset.attrs["unit"] = u"nm"

Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]