std::codecvt_byname (3) - Linux Manuals
std::codecvt_byname: std::codecvt_byname
NAME
std::codecvt_byname - std::codecvt_byname
Synopsis
Defined in header <locale>
template< class InternT, class ExternT, class State >
class codecvt_byname : public std::codecvt<InternT, ExternT, State>;
std::codecvt_byname is a std::codecvt facet which encapsulates multibyte/wide character conversion rules of a locale specified at its construction.
Four specializations are provided by the standard library
Defined in header <locale>
std::codecvt_byname<char, char, std::mbstate_t> identity conversion
std::codecvt_byname<char16_t, char, std::mbstate_t> conversion between UTF-16 and UTF-8 (since C++11)(deprecated in C++20)
std::codecvt_byname<char16_t, char8_t, std::mbstate_t> conversion between UTF-16 and UTF-8 (since C++20)
std::codecvt_byname<char32_t, char, std::mbstate_t> conversion between UTF-32 and UTF-8 (since C++11)(deprecated in C++20)
std::codecvt_byname<char32_t, char8_t, std::mbstate_t> conversion between UTF-32 and UTF-8 (since C++20)
std::codecvt_byname<wchar_t, char, std::mbstate_t> locale-specific conversion between wide string and narrow character sets
Member functions
constructor (public member function)
destructor (protected member function)
std::codecvt_byname::codecvt_byname
explicit codecvt_byname( const char* name, std::size_t refs = 0 );
explicit codecvt_byname( const std::string& name, std::size_t refs = 0 ); (since C++11)
Constructs a new std::codecvt_byname facet for a locale with name.
refs is used for resource management: if refs == 0, the implementation destroys the facet, when the last std::locale object holding it is destroyed. Otherwise, the object is not destroyed.
Parameters
name - the name of the locale
refs - the number of references that link to the facet
std::codecvt_byname::~codecvt_byname
protected:
~codecvt_byname();
Destroys the facet.
Inherited from std::codecvt
Member types
Member type Definition
intern_type internT
extern_type externT
state_type stateT
Member objects
Member name Type
id (static) std::locale::id
Member functions
out (public member function of std::codecvt<InternT,ExternT,State>)
in (public member function of std::codecvt<InternT,ExternT,State>)
unshift (public member function of std::codecvt<InternT,ExternT,State>)
encoding (public member function of std::codecvt<InternT,ExternT,State>)
always_noconv (public member function of std::codecvt<InternT,ExternT,State>)
length (public member function of std::codecvt<InternT,ExternT,State>)
max_length (public member function of std::codecvt<InternT,ExternT,State>)
Protected member functions
do_out converts a string from internT to externT, such as when writing to file
[virtual]
do_in converts a string from externT to internT, such as when reading from file
[virtual]
do_unshift generates the termination character sequence of externT characters for incomplete conversion
[virtual]
do_encoding returns the number of externT characters necessary to produce one internT character, if constant
[virtual]
do_always_noconv tests if the facet encodes an identity conversion for all valid argument values
[virtual]
do_length calculates the length of the externT string that would be consumed by conversion into given internT buffer
[virtual]
do_max_length returns the maximum number of externT characters that could be converted into a single internT character
[virtual]
Inherited from std::codecvt_base
Member type Definition
enum result { ok, partial, error, noconv }; Unscoped enumeration type
Enumeration constant Definition
ok conversion was completed with no error
partial not all source characters were converted
error encountered an invalid character
noconv no conversion required, input and output types are the same
Example
This example demonstrates reading a GB18030-encoded file using the codecvt facet from a GB18030-aware locale
// Run this code