Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: character encoding of NetCDF text attributes
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
SOCIB Data Center

Posts: 1
Registered: 5/15/14
character encoding of NetCDF text attributes
Posted: May 15, 2014 4:52 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Input and output of text attributes to NetCDF files
is not consistent when they contain non-ASCII characters.
Saving the attribute to a file and loading it again
doest not recover the original value.
The problem seems to be originated by the netcdflib mex interface
not dealing properly with the character encoding.

Basically, it seems that the mex interface deals with the encoding
in different ways when reading and when writing.
A demonstration of the problem with a detailed explanation of the causes
and some possible solutions may be found in this gist:

As a wokaround, when writing you can try something like this
(specify the desired encoding if it differs from the default one):
netcdf.putAtt(ncid, varid, attrame, char(unicode2native(attrtext)))

However, the best solution would be to patch to the netcdflib interface
to properly encode/decode the text attributes. I would like to contribute the fix
but the source code of the netcdflib interface is not available.

A bug has already been reported, but I wanted to share the issue
and the possible workarounds to help anyone else with the same problem.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.