Namespaces
Variants
Actions

std::text_encoding::text_encoding

From cppreference.com
< cpp‎ | text‎ | text encoding
 
 
 
 
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 .

[edit] Parameters

enc - character encoding name
i - MIBenum value

[edit] Example

View on Compiler Explorer.

Run this code
#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"));
}

[edit] External links

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/text/text_encoding/text_encoding&oldid=182553"

AltStyle によって変換されたページ (->オリジナル) /