Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2026-03-23 The HDF5 Field Guide

Loading...
Searching...
No Matches
Attribute Creation Properties
Property Lists (H5P) » String Creation Properties

## Detailed Description

The creation property, the choice of a character encoding, applies to attributes.

Attribute creation property list functions (H5P)
Function | Purpose
--- | ---
H5Pset_char_encoding/H5Pget_char_encoding | Sets/gets the character encoding used to encode link and attribute names.

See also
  String Creation Properties

## Functions
herr_t | H5Pget_char_encoding (hid_t plist_id, H5T_cset_t *encoding)
| Retrieves the character encoding used to create a link or attribute name.
herr_t | H5Pset_char_encoding (hid_t plist_id, H5T_cset_t encoding)
| Sets the character encoding used to encode link and attribute names.

## Function Documentation

## ◆ H5Pget_char_encoding()

herr_t H5Pget_char_encoding | ( | hid_t | plist_id,
|  | H5T_cset_t * | encoding )

Retrieves the character encoding used to create a link or attribute name.

Parameters

  [in] | plist_id | Link creation or attribute creation property list identifier
  [out] | encoding | String encoding character set

Returns
  Returns a non-negative value if successful; otherwise, returns a negative value.

H5Pget_char_encoding() retrieves the character encoding used to encode link or attribute names that are created with the property list `plist_id`.

Valid values for `encoding` are defined in H5Tpublic.h and include the following:

H5T_CSET_ASCII | US ASCII
H5T_CSET_UTF8 | UTF-8 Unicode encoding

Note
  H5Pget_char_encoding() retrieves the character set used for an HDF5 link or attribute name while H5Tget_cset() retrieves the character set used in a character or string datatype.

Since
  1.8.0

## ◆ H5Pset_char_encoding()

herr_t H5Pset_char_encoding | ( | hid_t | plist_id,
|  | H5T_cset_t | encoding )

Sets the character encoding used to encode link and attribute names.

Parameters

  [in] | plist_id | Link creation or attribute creation property list identifier
  [in] | encoding | String encoding character set

Returns
  Returns a non-negative value if successful; otherwise, returns a negative value.

H5Pset_char_encoding() sets the character encoding used for the names of links (which provide the names by which objects are referenced) or attributes created with the property list `plist_id`.

Valid values for encoding include the following:

H5T_CSET_ASCII | US ASCII
H5T_CSET_UTF8 | UTF-8 Unicode encoding

For example, if the character set for the property list `plist_id` is set to H5T_CSET_UTF8, link names pointing to objects created with the link creation property list `plist_id` will be encoded using the UTF-8 character set. Similarly, names of attributes created with the attribute creation property list `plist_id` will be encoded as UTF-8.

ASCII and UTF-8 Unicode are the only currently supported character encodings. Extended ASCII encodings (for example, ISO 8859) are not supported. This encoding policy is not enforced by the HDF5 library. Using encodings other than ASCII and UTF-8 can lead to compatibility and usability problems.

Note
  H5Pset_char_encoding() sets the character set used for an HDF5 link or attribute name while H5Tset_cset() sets the character set used in a character or string datatype.

Since
  1.8.0