Skip to content

Commit

Permalink
Switch NC_CHAR on netCDF4 to use ASCII
Browse files Browse the repository at this point in the history
Fixes GH298
  • Loading branch information
shoyer committed Mar 14, 2017
1 parent 2ad4b06 commit 4dd8e38
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/file_format_specifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ data are written). In that case the specified endian type will be used
in HDF5 (for example, a H5T_STD_I16LE will be used for NC_SHORT, if
little-endian has been specified for that variable.)
- NC_BYTE = H5T_NATIVE_SCHAR
- NC_UBYTE = H5T_NATIVE_SCHAR
- NC_UBYTE = H5T_NATIVE_UCHAR
- NC_CHAR = H5T_C_S1
- NC_STRING = variable length array of H5T_C_S1
- NC_SHORT = H5T_NATIVE_SHORT
Expand Down
2 changes: 1 addition & 1 deletion libsrc4/nc4hdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ nc4_get_hdf_typeid(NC_HDF5_FILE_INFO_T *h5, nc_type xtype,
return NC_EHDFERR;
if (H5Tset_strpad(typeid, H5T_STR_NULLTERM) < 0)
BAIL(NC_EVARMETA);
if(H5Tset_cset(typeid, H5T_CSET_UTF8) < 0)
if(H5Tset_cset(typeid, H5T_CSET_ASCII) < 0)
BAIL(NC_EVARMETA);

/* Take ownership of the newly created HDF5 datatype */
Expand Down
5 changes: 3 additions & 2 deletions nc_test4/tst_strings2.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ main(int argc, char **argv)
int ncid, i;
char *data_in[ATT_LEN];
char *data[ATT_LEN] = {"An appeaser is one who feeds a crocodile — "
"hoping it will eat him last."};

"hoping it will eat him last. "
"Here are some non-ASCII characters: "
"\x00\xAA\xBB\xFF"};

if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_put_att(ncid, NC_GLOBAL, ATT_NAME, NC_STRING, ATT_LEN, data)) ERR;
Expand Down

0 comments on commit 4dd8e38

Please sign in to comment.