Namespaces
Variants

std::text_encoding:: text_encoding

From cppreference.net
constexpr text_encoding ( ) = default ;
(1) (since C++26)
constexpr explicit text_encoding ( std:: string_view enc ) noexcept ;
(2) (since C++26)
constexpr text_encoding ( std :: text_encoding :: id i ) noexcept ;
(3) (since C++26)

Constructs a new text encoding object.

1) Default constructor. Constructs an object with MIBenum value std :: text_encoding :: id :: unknown and empty character encoding name .
2) Constructs an object with character encoding name enc .
If enc names a registered character encoding other than NATS-DANO or NATS-DANO-ADD , then the constructed object will have the corresponding MIBenum value, otherwise it will have MIBenum std :: text_encoding :: id :: other .
Behavior is undefined if enc. size ( ) > std :: text_encoding :: max_name_length || enc. contains ( ' \0 ' ) .
3) Constructs an object with MIBenum value i .
If i is std :: text_encoding :: id :: other or std :: text_encoding :: id :: unknown , then the constructed object will have empty character encoding name , otherwise it will have one of the corresponding names .
Behavior is undefined if i is not a named enumerator of std::text_encoding::id .

Parameters

enc - character encoding name
i - MIBenum value

Example

View on Compiler Explorer .

#include <text_encoding>
int main()
{
    constexpr std::text_encoding iso60 = std::text_encoding::ISO60DanishNorwegian;
    static_assert(iso60 == std::text_encoding("csISO60DanishNorwegian"));
    static_assert(iso60 == std::text_encoding("iso-ir-60"));
    static_assert(iso60 == std::text_encoding("NS_4551-1"));
}

External links

IANA registry of character set names and MIBenum values .