Namespaces
Variants
Actions

std::text_encoding

From cppreference.com
< cpp‎ | text
Defined in header <text_encoding>
struct text_encoding;
(since C++26)

The class text_encoding provides a mechanism for identifying character encodings. It is used to determine the ordinary character literal encoding of the translation environment at compile-time and the character encoding of the execution environment at runtime.

Each text_encoding object encapsulates a character encoding scheme, uniquely identified by an enumerator in text_encoding::id and a corresponding name represented by a null-terminated byte string. These can be accessed through the mib() and name() member functions, respectively. The determination of whether an object represents a character encoding scheme implemented in the translation or execution environment is implementation-defined.

The class text_encoding is a TriviallyCopyable type. The array object representing the corresponding name of the character encoding scheme is nested within the text_encoding object itself. The stored name is limited to a maximum of max_name_length characters excluding the null character '\0'.

The class supports both registered and non-registered character encodings. Registered encodings are those found in the IANA Character Sets Registry excluding the following character encodings:

  • NATS-DANO (33)
  • NATS-DANO-ADD (34).

In addition, the class provides access for registered character encodings to:

  1. Primary name: The official name specified in the registry.
  2. Aliases: An implementation-defined superset of aliases from the registry.
  3. MIBenum value: A unique identifier for use in identifying coded character encodings.

Non-registered encodings can be represented with an enumerator id::other or id::unknown and a custom name.

A text_encoding object e whose MIBenum value is neither id::other nor id::unknown maintains the following invariants:

Contents